summaryrefslogtreecommitdiffstats
path: root/lib/rbcodec/metadata
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2021-08-11 22:25:20 -0400
committerWilliam Wilgus <wilgus.william@gmail.com>2021-08-11 22:25:20 -0400
commit30945f1180962e013c049dcd433697c8a91b1b4c (patch)
tree42a65e2780c8a8896a2fa45c06deaf7457f590bb /lib/rbcodec/metadata
parentf05a7a10a6508b5ca6e3a191c2336d08eb24d1ea (diff)
downloadrockbox-30945f1180962e013c049dcd433697c8a91b1b4c.tar.gz
rockbox-30945f1180962e013c049dcd433697c8a91b1b4c.zip
metadata/metadata_common.c check read for proper bytes read
Change-Id: I25d7c20d449cde4d5cfd3f57e00ff45f4c14f60b
Diffstat (limited to 'lib/rbcodec/metadata')
-rw-r--r--lib/rbcodec/metadata/metadata_common.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/lib/rbcodec/metadata/metadata_common.c b/lib/rbcodec/metadata/metadata_common.c
index 45b2b90bf8..6fc50e9a9d 100644
--- a/lib/rbcodec/metadata/metadata_common.c
+++ b/lib/rbcodec/metadata/metadata_common.c
@@ -233,25 +233,23 @@ uint32_t get_itunes_int32(char* value, int count)
*/
bool skip_id3v2(int fd, struct mp3entry *id3)
{
- char buf[4];
-
- read(fd, buf, 4);
- if (memcmp(buf, "ID3", 3) == 0)
+ #define ID3TAGSZ 4
+ char buf[ID3TAGSZ];
+ bool success = (read(fd, buf, ID3TAGSZ) == ID3TAGSZ);
+ if (success && memcmp(buf, "ID3", 3) == 0)
{
/* We have found an ID3v2 tag at the start of the file - find its
length and then skip it. */
if ((id3->first_frame_offset = getid3v2len(fd)) == 0)
- return false;
-
- if ((lseek(fd, id3->first_frame_offset, SEEK_SET) < 0))
- return false;
+ success = false;
- return true;
+ if (success && (lseek(fd, id3->first_frame_offset, SEEK_SET) < 0))
+ success = false;
} else {
lseek(fd, 0, SEEK_SET);
id3->first_frame_offset = 0;
- return true;
}
+ return success;
}
/* Parse the tag (the name-value pair) and fill id3 and buffer accordingly.