]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
Fix a segfault in base64_encode_data_blob
authorVolker Lendecke <vl@samba.org>
Thu, 10 Jul 2008 16:12:24 +0000 (18:12 +0200)
committerVolker Lendecke <vl@samba.org>
Thu, 10 Jul 2008 16:24:46 +0000 (18:24 +0200)
We did not allocate enough memory for the \0 and a = at the end

source/lib/util_str.c

index 1e1108132cdf37b1aca169733dda5e0b46712529..7cb57adbb59acabc906e6030ca6769b35d90d59c 100644 (file)
@@ -2347,7 +2347,9 @@ char *base64_encode_data_blob(TALLOC_CTX *mem_ctx, 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 = TALLOC_ARRAY(mem_ctx, char, output_len); /* get us plenty of space */
        SMB_ASSERT(result != NULL);