Hi Team,
Function buffer_add in base64.c contains a bug:
void buffer_add(struct buffer_st b, char c)
{
(b->ptr++) = c; // (1) crash in next call due to invalid access
b->offset++;
if (b->offset == b->length) {
b->length += 512;
b->data = realloc(b->data, b->length); // (2) bug here, missing NULL check
b->ptr = b->data + b->offset; // (3) update b->ptr, if b->data = NULL, b->ptr = b->offset which will be an invalid address
}
}
There is a missing NULL check of realloc result which leads to a wrong update of b->ptr and finally crash in next call to this function with the same buffer b as parameter.
This base64.c file may not be created by you but can you fix it? Since some other projects is using your code and maybe affected as well.