larsbs / id3v2lib

id3v2lib is a library written in C to read and edit id3 tags from mp3 files.
BSD 2-Clause "Simplified" License
128 stars 44 forks source link

Crash when using frame->size without checking #34

Closed nrathaus closed 1 year ago

nrathaus commented 5 years ago

The line of code: frame->size = btoi(bytes, 4, offset += ID3_FRAME_ID);

Takes the value found inside the frame without looking whether or not the data that is expected is found, this can be used to cause a read overrun as: memcpy(frame->data, bytes + (offset += ID3_FRAME_FLAGS), frame->size);

Reads beyond the data

In addition, since size is an int a value that is negative can be returned, causing the allocation '0' in the malloc: frame->data = (char*) malloc(frame->size * sizeof(char));

And a memcpy into a NULL pointer