From 6fd5918b06a5550f460bfbe7f8328c158273608a Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 1 Feb 2005 18:24:39 +0000 Subject: r5158: BUG 2263: patch from Timur Bakeyev to guard base64_encode_data_blob() against empty blobs (This used to be commit 17239d609f63ae5bd6826e580876c27e8c92d6fa) --- source3/lib/util_str.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index 394c8e27cf..f99c2d1fb3 100644 --- a/source3/lib/util_str.c +++ b/source3/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++); -- cgit