History

libtags: vorbis, opus: ignore tags past the ogg page

As it is implemented right now, OGG pages are not treated properly, so in case of huge embedded pictures inside metadata the file could end up ignore by audio/readtags and audio/mkplist. Workaround by ignoring tags that span across pages for now.

Sigrid Solveig Haflínudóttir committed 4 years ago

Commit 3fc10ff1 parent 90b72c32 files · +16 −5Browse files

Unified · Split

2 files
  1. opus.c +7 −2
  2. vorbis.c +9 −3
opus.c+7−2
@@ -5,10 +5,10 @@ tagopus(Tagctx *ctx) · 4 unmodified lines
55 {
66 char *v;
77 uchar *d, h[4];
8− int sz, numtags, i, npages;
8+ int sz, numtags, i, npages, pgend;
99
1010 d = (uchar*)ctx->buf;
11− for(npages = 0; npages < 2; npages++){
11+ for(npages = pgend = 0; npages < 2; npages++){
1212 int nsegs;
1313 if(ctx->read(ctx, d, 27) != 27)
1414 return -1;
@@ -28,6 +28,8 @@ tagopus(Tagctx *ctx) · 13 unmodified lines
2828 ctx->channels = d[1];
2929 ctx->samplerate = leuint(&d[4]);
3030 }else if(memcmp(&d[nsegs], "OpusTags", 8) == 0){
31+ /* FIXME - embedded pics make tags span multiple packets */
32+ pgend = ctx->seek(ctx, 0, 1) + sz;
3133 break;
3234 }
3335
@@ -47,6 +49,9 @@ tagopus(Tagctx *ctx) · 13 unmodified lines
4749 return -1;
4850 if((sz = leuint(h)) < 0)
4951 return -1;
52+ /* FIXME - embedded pics make tags span multiple packets */
53+ if(pgend < ctx->seek(ctx, 0, 1)+sz)
54+ break;
5055
5156 if(ctx->bufsz < sz+1){
5257 if(ctx->seek(ctx, sz, 1) < 0)
vorbis.c+9−3
@@ -37,11 +37,11 @@ tagvorbis(Tagctx *ctx) · 36 unmodified lines
3737 {
3838 char *v;
3939 uchar *d, h[4];
40− int sz, numtags, i, npages;
40+ int sz, numtags, i, npages, pgend;
4141
4242 d = (uchar*)ctx->buf;
4343 /* need to find vorbis frame with type=3 */
44− for(npages = 0; npages < 2; npages++){ /* vorbis comment is the second header */
44+ for(npages = pgend = 0; npages < 2; npages++){ /* vorbis comment is the second header */
4545 int nsegs;
4646 if(ctx->read(ctx, d, 27) != 27)
4747 return -1;
@@ -54,8 +54,11 @@ tagvorbis(Tagctx *ctx) · 6 unmodified lines
5454 return -1;
5555 for(sz = i = 0; i < nsegs; sz += d[i++]);
5656
57− if(d[nsegs] == 3) /* comment */
57+ if(d[nsegs] == 3){ /* comment */
58+ /* FIXME - embedded pics make tags span multiple packets */
59+ pgend = ctx->seek(ctx, 0, 1) + sz;
5860 break;
61+ }
5962 if(d[nsegs] == 1 && sz >= 28){ /* identification */
6063 if(ctx->read(ctx, d, 28) != 28)
6164 return -1;
@@ -82,6 +85,9 @@ tagvorbis(Tagctx *ctx) · 20 unmodified lines
8285 return -1;
8386 if((sz = leuint(h)) < 0)
8487 return -1;
88+ /* FIXME - embedded pics make tags span multiple packets */
89+ if(pgend < ctx->seek(ctx, 0, 1)+sz)
90+ break;
8591
8692 if(ctx->bufsz < sz+1){
8793 if(ctx->seek(ctx, sz, 1) < 0)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t