From ee0257dc88c625aae243b3ff244bf91a00153553 Mon Sep 17 00:00:00 2001 From: cathugger Date: Thu, 12 Jul 2018 11:56:43 +0000 Subject: [PATCH] stronger base64 validation --- base64_from.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/base64_from.c b/base64_from.c index 808bf1d..3f96748 100644 --- a/base64_from.c +++ b/base64_from.c @@ -84,10 +84,10 @@ int base64_valid(const char *src,size_t *count) for (p = src;base64f[(u8)*p] != 0xFF;++p) ; - for (;*p == '=';++p) + for (;((size_t) (p - src)) % 4 != 0 && *p == '=';++p) ; if (count) *count = (size_t) (p - src); - return !*p; + return !*p && ((size_t) (p - src)) % 4 == 0; }