diff options
Diffstat (limited to 'lib/rbcodec/metadata')
-rw-r--r-- | lib/rbcodec/metadata/metadata_common.c | 18 |
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) | |||
233 | */ | 233 | */ |
234 | bool skip_id3v2(int fd, struct mp3entry *id3) | 234 | bool skip_id3v2(int fd, struct mp3entry *id3) |
235 | { | 235 | { |
236 | char buf[4]; | 236 | #define ID3TAGSZ 4 |
237 | 237 | char buf[ID3TAGSZ]; | |
238 | read(fd, buf, 4); | 238 | bool success = (read(fd, buf, ID3TAGSZ) == ID3TAGSZ); |
239 | if (memcmp(buf, "ID3", 3) == 0) | 239 | if (success && memcmp(buf, "ID3", 3) == 0) |
240 | { | 240 | { |
241 | /* We have found an ID3v2 tag at the start of the file - find its | 241 | /* We have found an ID3v2 tag at the start of the file - find its |
242 | length and then skip it. */ | 242 | length and then skip it. */ |
243 | if ((id3->first_frame_offset = getid3v2len(fd)) == 0) | 243 | if ((id3->first_frame_offset = getid3v2len(fd)) == 0) |
244 | return false; | 244 | success = false; |
245 | |||
246 | if ((lseek(fd, id3->first_frame_offset, SEEK_SET) < 0)) | ||
247 | return false; | ||
248 | 245 | ||
249 | return true; | 246 | if (success && (lseek(fd, id3->first_frame_offset, SEEK_SET) < 0)) |
247 | success = false; | ||
250 | } else { | 248 | } else { |
251 | lseek(fd, 0, SEEK_SET); | 249 | lseek(fd, 0, SEEK_SET); |
252 | id3->first_frame_offset = 0; | 250 | id3->first_frame_offset = 0; |
253 | return true; | ||
254 | } | 251 | } |
252 | return success; | ||
255 | } | 253 | } |
256 | 254 | ||
257 | /* Parse the tag (the name-value pair) and fill id3 and buffer accordingly. | 255 | /* Parse the tag (the name-value pair) and fill id3 and buffer accordingly. |