From 084aa8c44b71adb212ef4ca504d0034302372bd7 Mon Sep 17 00:00:00 2001 From: Pol Henarejos Date: Tue, 5 May 2026 01:55:22 +0200 Subject: [PATCH] Fix when olen == 0 Signed-off-by: Pol Henarejos --- src/crypto_utils.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/crypto_utils.c b/src/crypto_utils.c index 9be06db..9fd9af4 100644 --- a/src/crypto_utils.c +++ b/src/crypto_utils.c @@ -313,6 +313,9 @@ int base64url_encode(unsigned char *dst, size_t dlen, size_t *olen, const unsign dst[i] = '_'; } } + if (*olen == 0) { + return 0; + } uint8_t *p = dst + *olen - 1; while (*p == '=') { *p-- = '\0'; @@ -363,4 +366,4 @@ int b64url_decoded_len(size_t n, size_t *out_len) { *out_len = out; return 0; -} \ No newline at end of file +}