mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-10 05:32:40 -05:00
metadata/metadata_common.c check read for proper bytes read
Change-Id: I25d7c20d449cde4d5cfd3f57e00ff45f4c14f60b
This commit is contained in:
parent
f05a7a10a6
commit
30945f1180
1 changed files with 8 additions and 10 deletions
|
|
@ -233,25 +233,23 @@ uint32_t get_itunes_int32(char* value, int count)
|
||||||
*/
|
*/
|
||||||
bool skip_id3v2(int fd, struct mp3entry *id3)
|
bool skip_id3v2(int fd, struct mp3entry *id3)
|
||||||
{
|
{
|
||||||
char buf[4];
|
#define ID3TAGSZ 4
|
||||||
|
char buf[ID3TAGSZ];
|
||||||
read(fd, buf, 4);
|
bool success = (read(fd, buf, ID3TAGSZ) == ID3TAGSZ);
|
||||||
if (memcmp(buf, "ID3", 3) == 0)
|
if (success && memcmp(buf, "ID3", 3) == 0)
|
||||||
{
|
{
|
||||||
/* We have found an ID3v2 tag at the start of the file - find its
|
/* We have found an ID3v2 tag at the start of the file - find its
|
||||||
length and then skip it. */
|
length and then skip it. */
|
||||||
if ((id3->first_frame_offset = getid3v2len(fd)) == 0)
|
if ((id3->first_frame_offset = getid3v2len(fd)) == 0)
|
||||||
return false;
|
success = false;
|
||||||
|
|
||||||
if ((lseek(fd, id3->first_frame_offset, SEEK_SET) < 0))
|
if (success && (lseek(fd, id3->first_frame_offset, SEEK_SET) < 0))
|
||||||
return false;
|
success = false;
|
||||||
|
|
||||||
return true;
|
|
||||||
} else {
|
} else {
|
||||||
lseek(fd, 0, SEEK_SET);
|
lseek(fd, 0, SEEK_SET);
|
||||||
id3->first_frame_offset = 0;
|
id3->first_frame_offset = 0;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parse the tag (the name-value pair) and fill id3 and buffer accordingly.
|
/* Parse the tag (the name-value pair) and fill id3 and buffer accordingly.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue