diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/metadata.c | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/apps/metadata.c b/apps/metadata.c index 28f5f04aed..2f60b11fa6 100644 --- a/apps/metadata.c +++ b/apps/metadata.c | |||
@@ -328,7 +328,6 @@ bool get_metadata(struct mp3entry* id3, int fd, const char* trackname) | |||
328 | #if CONFIG_CODEC == SWCODEC | 328 | #if CONFIG_CODEC == SWCODEC |
329 | void strip_tags(int handle_id) | 329 | void strip_tags(int handle_id) |
330 | { | 330 | { |
331 | int i; | ||
332 | static const unsigned char tag[] = "TAG"; | 331 | static const unsigned char tag[] = "TAG"; |
333 | static const unsigned char apetag[] = "APETAGEX"; | 332 | static const unsigned char apetag[] = "APETAGEX"; |
334 | size_t len, version; | 333 | size_t len, version; |
@@ -337,27 +336,24 @@ void strip_tags(int handle_id) | |||
337 | if (bufgettail(handle_id, 128, (void **)&tail) != 128) | 336 | if (bufgettail(handle_id, 128, (void **)&tail) != 128) |
338 | return; | 337 | return; |
339 | 338 | ||
340 | for(i = 0;i < 3;i++) | 339 | if (memcmp(tail, tag, 3) == 0) |
341 | if(tail[i] != tag[i]) | 340 | { |
342 | goto strip_ape_tag; | 341 | /* Skip id3v1 tag */ |
343 | 342 | logf("Cutting off ID3v1 tag"); | |
344 | /* Skip id3v1 tag */ | 343 | bufcuttail(handle_id, 128); |
345 | logf("Cutting off ID3v1 tag"); | 344 | } |
346 | bufcuttail(handle_id, 128); | ||
347 | |||
348 | strip_ape_tag: | ||
349 | /* Check for APE tag (look for the APE tag footer) */ | ||
350 | 345 | ||
346 | /* Get a new tail, as the old one may have been cut */ | ||
351 | if (bufgettail(handle_id, 32, (void **)&tail) != 32) | 347 | if (bufgettail(handle_id, 32, (void **)&tail) != 32) |
352 | return; | 348 | return; |
353 | 349 | ||
354 | for(i = 0;i < 8;i++) | 350 | /* Check for APE tag (look for the APE tag footer) */ |
355 | if(tail[i] != apetag[i]) | 351 | if (memcmp(tail, apetag, 8) != 0) |
356 | return; | 352 | return; |
357 | 353 | ||
358 | /* Read the version and length from the footer */ | 354 | /* Read the version and length from the footer */ |
359 | version = tail[8] | (tail[9] << 8) | (tail[10] << 16) | (tail[11] << 24); | 355 | version = get_long_le(&tail[8]); |
360 | len = tail[12] | (tail[13] << 8) | (tail[14] << 16) | (tail[15] << 24); | 356 | len = get_long_le(&tail[12]); |
361 | if (version == 2000) | 357 | if (version == 2000) |
362 | len += 32; /* APEv2 has a 32 byte header */ | 358 | len += 32; /* APEv2 has a 32 byte header */ |
363 | 359 | ||