diff options
-rw-r--r-- | junklib.c | 24 | ||||
-rw-r--r-- | plugins/ffap/ffap.c | 10 |
2 files changed, 25 insertions, 9 deletions
@@ -2447,16 +2447,21 @@ junk_id3v2_read_full (playItem_t *it, DB_id3v2_tag_t *tag_store, DB_FILE *fp) { uint8_t flags2 = readptr[1]; readptr += 2; + if (sz > MAX_ID3V2_FRAME_SIZE || readptr-tag + sz >= size) { + trace ("junk_id3v2_read_full: frame %s size is too big, discarded\n", frameid); + readptr += sz; + continue; + } int synched_size = sz; if (unsync) { synched_size = junklib_id3v2_sync_frame (readptr, sz); - } + trace ("size: %d/%d\n", synched_size, sz); - if (sz > MAX_ID3V2_FRAME_SIZE) { - trace ("junk_id3v2_read_full: frame %s size is too big, discarded\n", frameid); - readptr += sz; - continue; + if (synched_size != sz) { + sz = sz + (sz-synched_size); + } } + if (tag_store) { DB_id3v2_frame_t *frm = malloc (sizeof (DB_id3v2_frame_t) + sz); if (!frm) { @@ -2548,8 +2553,12 @@ junk_id3v2_read_full (playItem_t *it, DB_id3v2_tag_t *tag_store, DB_FILE *fp) { const char *text_frames[] = { "TPE1", "TPE2", "TPOS", "TIT2", "TALB", "TCOP", "TCON", "TENC", "TPE3", "TCOM", "TRCK", "TYER", "TDRC", NULL }; char **text_holders[] = { &artist, &band, &disc, &title, &album, ©right, &genre, &vendor, &performer, &composer, &track, version_major == 3 ? &year : NULL, version_major == 4 ? &year : NULL, }; int f = 0; + + int added = 0; + for (f = 0; text_frames[f]; f++) { if (!strcmp (frameid, text_frames[f])) { + added = 1; if (synched_size > MAX_TEXT_FRAME_SIZE) { trace ("frame %s is too big, discard\n", frameid); break; @@ -2576,6 +2585,11 @@ junk_id3v2_read_full (playItem_t *it, DB_id3v2_tag_t *tag_store, DB_FILE *fp) { } } + if (added) { + readptr += sz; + continue; + } + if (!strcmp (frameid, "COMM")) { if (sz < 4) { trace ("COMM frame is too short, skipped\n"); diff --git a/plugins/ffap/ffap.c b/plugins/ffap/ffap.c index 10926881..f1ffdca6 100644 --- a/plugins/ffap/ffap.c +++ b/plugins/ffap/ffap.c @@ -37,10 +37,10 @@ #include <assert.h> #include "../../deadbeef.h" -#define ENABLE_DEBUG 0 +#define ENABLE_DEBUG 1 -//#define trace(...) { fprintf(stderr, __VA_ARGS__); } -#define trace(fmt,...) +#define trace(...) { fprintf(stderr, __VA_ARGS__); } +//#define trace(fmt,...) #define likely(x) __builtin_expect((x),1) #define unlikely(x) __builtin_expect((x),0) @@ -264,6 +264,7 @@ typedef struct APEContext { int remaining; int error; + int skip_header; } APEContext; typedef struct { @@ -598,7 +599,7 @@ static int ape_read_packet(DB_FILE *fp, APEContext *ape_ctx) if (ape->currentframe > ape->totalframes) return -1; // fprintf (stderr, "seeking to %d\n", ape->frames[ape->currentframe].pos); - if (deadbeef->fseek (fp, ape->frames[ape->currentframe].pos, SEEK_SET) != 0) { + if (deadbeef->fseek (fp, ape->frames[ape->currentframe].pos + ape_ctx->skip_header, SEEK_SET) != 0) { return -1; } @@ -684,6 +685,7 @@ ffap_init(DB_playItem_t *it) int skip = deadbeef->junk_get_leading_size (info->fp); if (skip > 0) { deadbeef->fseek (info->fp, skip, SEEK_SET); + info->ape_ctx.skip_header = skip; } ape_read_header (info->fp, &info->ape_ctx); int i; |