summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2005-02-01 18:24:39 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:55:30 -0500
commit6fd5918b06a5550f460bfbe7f8328c158273608a (patch)
treeed74b946eea2102f16fa847e81f6e3628fe2171d /source3/lib
parent6c6e231f15c100f1f3449f2656257e120b1071af (diff)
downloadsamba-6fd5918b06a5550f460bfbe7f8328c158273608a.tar.gz
samba-6fd5918b06a5550f460bfbe7f8328c158273608a.tar.bz2
samba-6fd5918b06a5550f460bfbe7f8328c158273608a.zip
r5158: BUG 2263: patch from Timur Bakeyev <timur@com.bat.ru> to guard base64_encode_data_blob() against empty blobs
(This used to be commit 17239d609f63ae5bd6826e580876c27e8c92d6fa)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/util_str.c14
1 files 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++);