Fix memory corruption in bytes().appendb64()

This commit is contained in:
s-hadinger 2025-02-15 22:08:00 +01:00 committed by GitHub
parent a939b4973e
commit cfc11b5e83
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1399,7 +1399,7 @@ static int m_appendb64(bvm *vm)
if (idx + len >= attr2.len) { len = attr2.len - idx; }
}
if (len > 0) { /* only if there is something to encode */
bytes_resize(vm, &attr, attr.len + encode_base64_length(len)); /* resize */
bytes_resize(vm, &attr, attr.len + encode_base64_length(len) + 1); /* resize */
size_t converted = encode_base64(attr2.bufptr + idx, len, (unsigned char*)(attr.bufptr + attr.len));
attr.len += converted;