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
5{5{
6 char *v;6 char *v;
7 uchar *d, h[4];7 uchar *d, h[4];
8 int sz, numtags, i, npages;8 int sz, numtags, i, npages, pgend;
9 9
10 d = (uchar*)ctx->buf;10 d = (uchar*)ctx->buf;
11 for(npages = 0; npages < 2; npages++){11 for(npages = pgend = 0; npages < 2; npages++){
12 int nsegs;12 int nsegs;
13 if(ctx->read(ctx, d, 27) != 27)13 if(ctx->read(ctx, d, 27) != 27)
14 return -1;14 return -1;
@@ -28,6 +28,8 @@ tagopus(Tagctx *ctx) · 13 unmodified lines
28 ctx->channels = d[1];28 ctx->channels = d[1];
29 ctx->samplerate = leuint(&d[4]);29 ctx->samplerate = leuint(&d[4]);
30 }else if(memcmp(&d[nsegs], "OpusTags", 8) == 0){30 }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;
31 break;33 break;
32 }34 }
33 35
@@ -47,6 +49,9 @@ tagopus(Tagctx *ctx) · 13 unmodified lines
47 return -1;49 return -1;
48 if((sz = leuint(h)) < 0)50 if((sz = leuint(h)) < 0)
49 return -1;51 return -1;
52 /* FIXME - embedded pics make tags span multiple packets */
53 if(pgend < ctx->seek(ctx, 0, 1)+sz)
54 break;
50 55
51 if(ctx->bufsz < sz+1){56 if(ctx->bufsz < sz+1){
52 if(ctx->seek(ctx, sz, 1) < 0)57 if(ctx->seek(ctx, sz, 1) < 0)
vorbis.c+9−3
@@ -37,11 +37,11 @@ tagvorbis(Tagctx *ctx) · 36 unmodified lines
37{37{
38 char *v;38 char *v;
39 uchar *d, h[4];39 uchar *d, h[4];
40 int sz, numtags, i, npages;40 int sz, numtags, i, npages, pgend;
41 41
42 d = (uchar*)ctx->buf;42 d = (uchar*)ctx->buf;
43 /* need to find vorbis frame with type=3 */43 /* 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 */
45 int nsegs;45 int nsegs;
46 if(ctx->read(ctx, d, 27) != 27)46 if(ctx->read(ctx, d, 27) != 27)
47 return -1;47 return -1;
@@ -54,8 +54,11 @@ tagvorbis(Tagctx *ctx) · 6 unmodified lines
54 return -1;54 return -1;
55 for(sz = i = 0; i < nsegs; sz += d[i++]);55 for(sz = i = 0; i < nsegs; sz += d[i++]);
56 56
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;
58 break;60 break;
61 }
59 if(d[nsegs] == 1 && sz >= 28){ /* identification */62 if(d[nsegs] == 1 && sz >= 28){ /* identification */
60 if(ctx->read(ctx, d, 28) != 28)63 if(ctx->read(ctx, d, 28) != 28)
61 return -1;64 return -1;
@@ -82,6 +85,9 @@ tagvorbis(Tagctx *ctx) · 20 unmodified lines
82 return -1;85 return -1;
83 if((sz = leuint(h)) < 0)86 if((sz = leuint(h)) < 0)
84 return -1;87 return -1;
88 /* FIXME - embedded pics make tags span multiple packets */
89 if(pgend < ctx->seek(ctx, 0, 1)+sz)
90 break;
85 91
86 if(ctx->bufsz < sz+1){92 if(ctx->bufsz < sz+1){
87 if(ctx->seek(ctx, sz, 1) < 0)93 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