From 5c007600dcdfd60b0ef8f164716573ee644869a1 Mon Sep 17 00:00:00 2001 From: Douglas Bagnall Date: Fri, 13 May 2022 10:59:24 +1200 Subject: [PATCH] util/base64: add a note about zero length strings Signed-off-by: Douglas Bagnall Reviewed-by: Andrew Bartlett --- lib/util/base64.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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; -- 2.47.3