From 4e436dec02cfee380a3dd682b431879ba3dc0950 Mon Sep 17 00:00:00 2001 From: Sebastian Reimers Date: Sat, 20 May 2023 17:47:02 +0200 Subject: [PATCH] base64: fix cppcheck warnings --- src/base64/b64.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/base64/b64.c b/src/base64/b64.c index 7285dc6c8..b17e3f865 100644 --- a/src/base64/b64.c +++ b/src/base64/b64.c @@ -83,12 +83,12 @@ int base64_encode(const uint8_t *in, size_t ilen, char *out, size_t *olen) */ int base64url_encode(const uint8_t *in, size_t ilen, char *out, size_t *olen) { - const uint8_t *in_end = in + ilen; - const char *o = out; - if (!in || !out || !olen) return EINVAL; + const uint8_t *in_end = in + ilen; + const char *o = out; + if (*olen < 4 * ((ilen+2)/3)) return EOVERFLOW; @@ -185,12 +185,12 @@ static inline uint32_t b64val(char c) */ int base64_decode(const char *in, size_t ilen, uint8_t *out, size_t *olen) { - const char *in_end = in + ilen; - const uint8_t *o = out; - if (!in || !out || !olen) return EINVAL; + const char *in_end = in + ilen; + const uint8_t *o = out; + if (*olen < 3 * (ilen/4)) return EOVERFLOW;