From a33dcc6ac77a26e6b88cc2ff5cca93e20019df76 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 10 Jul 2008 10:05:00 -0700 Subject: [PATCH] Fix from Volker. Fix a segfault in base64_encode_data_blob We did not allocate enough memory for the \0 and a = at the end. Jeremy. --- source/lib/util_str.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/lib/util_str.c b/source/lib/util_str.c index 3059a1b6bdd..c4d67c6b7c9 100644 --- a/source/lib/util_str.c +++ b/source/lib/util_str.c @@ -2308,7 +2308,9 @@ char * base64_encode_data_blob(DATA_BLOB data) out_cnt = 0; len = data.length; - output_len = data.length * 2; + output_len = data.length * 2 + 4; /* Account for closing bytes. 4 is + * random but should be enough for + * the = and \0 */ result = (char *)SMB_MALLOC(output_len); /* get us plenty of space */ while (len-- && out_cnt < (data.length * 2) - 5) { -- 2.11.4.GIT