From: Gerald Carter Date: Tue, 1 Feb 2005 18:24:39 +0000 (+0000) Subject: r5158: BUG 2263: patch from Timur Bakeyev to guard base64_encode_d... X-Git-Tag: samba-misc-tags/initial-v3-0-unstable~5316 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=17239d609f63ae5bd6826e580876c27e8c92d6fa;p=thirdparty%2Fsamba.git r5158: BUG 2263: patch from Timur Bakeyev to guard base64_encode_data_blob() against empty blobs --- diff --git a/source/lib/util_str.c b/source/lib/util_str.c index 394c8e27cff..f99c2d1fb32 100644 --- a/source/lib/util_str.c +++ b/source/lib/util_str.c @@ -2016,10 +2016,16 @@ char * base64_encode_data_blob(DATA_BLOB data) { int bits = 0; int char_count = 0; - size_t out_cnt = 0; - size_t len = data.length; - size_t output_len = data.length * 2; - char *result = SMB_MALLOC(output_len); /* get us plenty of space */ + size_t out_cnt, len, output_len; + char *result; + + if (!data.length || !data.data) + return NULL; + + out_cnt = 0; + len = data.length; + output_len = data.length * 2; + result = SMB_MALLOC(output_len); /* get us plenty of space */ while (len-- && out_cnt < (data.length * 2) - 5) { int c = (unsigned char) *(data.data++);