summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorWilliam Wilgus <me.theuser@yahoo.com>2018-12-08 01:44:34 -0600
committerWilliam Wilgus <me.theuser@yahoo.com>2018-12-08 20:30:12 +0100
commited63ef077a8f6d95dd9038ca0503e8372144010a (patch)
treeeb609510c1a4387b26a0a2c92a5393cd5dd1f148 /lib
parent78b2d135671c798dbbc36086cbbf278038d34669 (diff)
downloadrockbox-ed63ef077a8f6d95dd9038ca0503e8372144010a.tar.gz
rockbox-ed63ef077a8f6d95dd9038ca0503e8372144010a.tar.bz2
rockbox-ed63ef077a8f6d95dd9038ca0503e8372144010a.zip
Fix overlapping string region ape.c->read_ape_tags
Switch to strrchr to find the extension Change-Id: Id7ea01ecc2e0553f560308f8b0fc53bd33b023e5
Diffstat (limited to 'lib')
-rw-r--r--lib/rbcodec/metadata/ape.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/lib/rbcodec/metadata/ape.c b/lib/rbcodec/metadata/ape.c
index 1460e4aa95..d6457eab63 100644
--- a/lib/rbcodec/metadata/ape.c
+++ b/lib/rbcodec/metadata/ape.c
@@ -124,7 +124,7 @@ bool read_ape_tags(int fd, struct mp3entry* id3)
return false;
}
- if (!strcasecmp(name, "cuesheet"))
+ if (strcasecmp(name, "cuesheet") == 0)
{
id3->has_embedded_cuesheet = true;
id3->embedded_cuesheet.pos = lseek(fd, 0, SEEK_CUR)-item.length;
@@ -152,17 +152,24 @@ bool read_ape_tags(int fd, struct mp3entry* id3)
}
/* Gather the album art format from the pseudo file name's ending. */
- strcpy(name, name + strlen(name) - 4);
+ /* strcpy(name, name + strlen(name) - 4); */
id3->albumart.type = AA_TYPE_UNKNOWN;
- if (strcasecmp(name, ".jpg") == 0)
+ char *ext = strrchr(name, '.');
+ if (ext)
{
- id3->albumart.type = AA_TYPE_JPG;
+ if (strcasecmp(ext, ".jpg") == 0)
+ {
+ id3->albumart.type = AA_TYPE_JPG;
+ }
+ else if (strcasecmp(ext, ".jpeg") == 0)
+ {
+ id3->albumart.type = AA_TYPE_JPG;
+ }
+ else if (strcasecmp(ext, ".png") == 0)
+ {
+ id3->albumart.type = AA_TYPE_PNG;
+ }
}
- else if (strcasecmp(name, ".png") == 0)
- {
- id3->albumart.type = AA_TYPE_PNG;
- }
-
/* Set the album art size and position. */
if (id3->albumart.type != AA_TYPE_UNKNOWN)
{