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 +}