Handle EOF properly in get_flac_metadata

Change-Id: I5e581990046a9f4a0859787aff2fd6fc06fbf7f5
This commit is contained in:
Yuxuan Shui 2019-05-12 15:36:52 +01:00 committed by Solomon Peachy
parent e4ccd23bac
commit 5758a055fb
2 changed files with 3 additions and 2 deletions

View file

@ -697,6 +697,7 @@ Boris Kovačević
Stéphane Moutard-Martin Stéphane Moutard-Martin
Rune Pade Rune Pade
Michael Rey Michael Rey
Yuxuan Shui
The libmad team The libmad team
The wavpack team The wavpack team

View file

@ -59,7 +59,7 @@ bool get_flac_metadata(int fd, struct mp3entry* id3)
unsigned long i; unsigned long i;
int type; int type;
if (read(fd, buf, 4) < 0) if (read(fd, buf, 4) != 4)
{ {
return rc; return rc;
} }
@ -73,7 +73,7 @@ bool get_flac_metadata(int fd, struct mp3entry* id3)
{ {
unsigned long totalsamples; unsigned long totalsamples;
if (i >= sizeof(id3->path) || read(fd, buf, i) < 0) if (i >= sizeof(id3->path) || read(fd, buf, i) != i)
{ {
return rc; return rc;
} }