mirror of
https://github.com/open62541/open62541.git
synced 2025-06-03 04:00:21 +00:00
fix(core): Avoid buffer overflow in base64 decoding (length check)
This commit is contained in:
parent
17776739a3
commit
95b3deb6a1
10
deps/base64.c
vendored
10
deps/base64.c
vendored
@ -92,9 +92,19 @@ UA_unbase64(const unsigned char *src, size_t len, size_t *out_len) {
|
||||
}
|
||||
|
||||
if(pad1) {
|
||||
if (last + 1 >= len) {
|
||||
UA_free(str);
|
||||
*out_len = 0;
|
||||
return (unsigned char*)UA_EMPTY_ARRAY_SENTINEL;
|
||||
}
|
||||
uint32_t n = from_b64[p[last]] << 18 | from_b64[p[last + 1]] << 12;
|
||||
*pos++ = (unsigned char)(n >> 16);
|
||||
if(pad2) {
|
||||
if (last + 2 >= len) {
|
||||
UA_free(str);
|
||||
*out_len = 0;
|
||||
return (unsigned char*)UA_EMPTY_ARRAY_SENTINEL;
|
||||
}
|
||||
n |= from_b64[p[last + 2]] << 6;
|
||||
*pos++ = (unsigned char)(n >> 8 & 0xFF);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user