From: Douglas Bagnall Date: Thu, 12 May 2022 22:59:24 +0000 (+1200) Subject: util/base64: add a note about zero length strings X-Git-Tag: tevent-0.16.0~1089 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5c007600dcdfd60b0ef8f164716573ee644869a1;p=thirdparty%2Fsamba.git util/base64: add a note about zero length strings Signed-off-by: Douglas Bagnall Reviewed-by: Andrew Bartlett --- diff --git a/lib/util/base64.c b/lib/util/base64.c index 842c22ffdb0..7acc83d0eaf 100644 --- a/lib/util/base64.c +++ b/lib/util/base64.c @@ -115,8 +115,16 @@ _PUBLIC_ char *base64_encode_data_blob(TALLOC_CTX *mem_ctx, DATA_BLOB data) size_t out_cnt, len, output_len; char *result; - if (!data.length || !data.data) + /* + * Note: we return NULL for a zero-length blob, even though it can be + * encoded as a zero length string in base64. + * + * FIXME, perhaps, but we need to check carefully before changing + * this. + */ + if (data.length == 0 || data.data == NULL) { return NULL; + } out_cnt = 0; len = data.length;