summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Jackson <rdjackso@rockbox.org>2005-07-28 20:21:54 +0000
committerRyan Jackson <rdjackso@rockbox.org>2005-07-28 20:21:54 +0000
commit9e35640fcc86ca9ed1f49a9c8c0585abb2f55f01 (patch)
treea4447b2475d715a728e7d7ae3d2f45f21aad77c0
parentb301b438259ca637826ce2c47367e9c45cd0742b (diff)
downloadrockbox-9e35640fcc86ca9ed1f49a9c8c0585abb2f55f01.zip
rockbox-9e35640fcc86ca9ed1f49a9c8c0585abb2f55f01.tar.gz
rockbox-9e35640fcc86ca9ed1f49a9c8c0585abb2f55f01.tar.bz2
rockbox-9e35640fcc86ca9ed1f49a9c8c0585abb2f55f01.tar.xz
Fixed a bug that prevented the last tag in a flac file from being read.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7254 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/metadata.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/apps/metadata.c b/apps/metadata.c
index 524f521..ddcf456 100644
--- a/apps/metadata.c
+++ b/apps/metadata.c
@@ -332,11 +332,6 @@ bool get_metadata(struct track_info* track, int fd, const char* trackname,
return(false);
}
- /* Set id3v1 genre to 255 (effectively 'none'), otherwise vorbis tracks
- * without genre tags will show up as 'Blues'
- */
- track->id3.genre=255;
-
/* We now need to search for the last page in the file - identified by
by ('O','g','g','S',0) and retrieve totalsamples */
@@ -848,6 +843,11 @@ static bool get_vorbis_comments (struct mp3entry *entry, size_t bytes_remaining,
/* We've read in all header info, now start reading comments */
+ /* Set id3v1 genre to 255 (effectively 'none'), otherwise tracks
+ * without genre tags will show up as 'Blues'
+ */
+ track->id3.genre=255;
+
if (read(fd, &vendor_length, 4) < 4) {
return false;
}
@@ -866,6 +866,11 @@ static bool get_vorbis_comments (struct mp3entry *entry, size_t bytes_remaining,
for ( i = 0; i < comment_count; i++ ) {
int name_length = 0;
+ if (bytes_remaining < 4) {
+ break;
+ }
+ bytes_remaining -= 4;
+
if (read(fd, &comment_length, 4) < 4) {
return false;
}
@@ -873,10 +878,10 @@ static bool get_vorbis_comments (struct mp3entry *entry, size_t bytes_remaining,
little_endian_to_native(&comment_length, "L");
/* Quit if we've passed the end of the page */
- bytes_remaining -= (comment_length + 4);
- if ( bytes_remaining <= 0 ) {
- return true;
+ if ( bytes_remaining < (unsigned)comment_length ) {
+ break;
}
+ bytes_remaining -= (comment_length);
/* Skip comment if it won't fit in buffer */
if ( (unsigned int)comment_length >= sizeof(temp) ) {
@@ -933,5 +938,10 @@ static bool get_vorbis_comments (struct mp3entry *entry, size_t bytes_remaining,
}
}
+ /* Skip to the end of the block */
+ if (bytes_remaining) {
+ lseek(fd, bytes_remaining, SEEK_CUR);
+ }
+
return true;
}