Fix when olen == 0

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos
2026-05-05 01:55:22 +02:00
parent e0a8380dcd
commit 084aa8c44b

View File

@@ -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;
}
}