changeset 875:92fcaa240219

base64: properly handle zero length input during decode Without this explicit check we were accessing memory out-of-bounds (at index -1). Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Thu, 13 Jun 2019 00:34:37 +0300
parents 18a6543019cb
children 869264dad80b
files base64.c
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/base64.c	Thu Jun 13 00:19:24 2019 +0300
+++ b/base64.c	Thu Jun 13 00:34:37 2019 +0300
@@ -186,6 +186,11 @@
 	size_t groups;
 	size_t i;
 
+	/* special case: empty input means empty output */
+	if (!inlen)
+		return 0;
+
+	/* must have full groups */
 	if (inlen % 4)
 		return -1;