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

Check result of fread call #38

Closed pascal-cuoq closed 3 years ago

pascal-cuoq commented 3 years ago

The function get_tag_header calls fread(buffer, ID3_HEADER, 1, file) to indicate that it absolutely needs 10 bytes to work on, but it doesn't assign the result of this call. When the file is shorter than 10 bytes, the fread call returns 0 and leaves buffer indeterminate. In these conditions, buffer should not be passed to the function get_tag_header_with_buffer, which would find itself processing indeterminate data.

This pull request makes get_tag_header return NULL when the fread call returns 0.

larsbs commented 3 years ago

Thanks for your contribution 👍