ref: 3fc10ff7882bee4063ee12c03d5a5e23c172f3cc
parent: 90b72c3a3282241e608f8bf778003f8afc96fdac
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Wed Oct 12 21:18:53 EDT 2022
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.
--- a/opus.c
+++ b/opus.c
@@ -5,10 +5,10 @@
{
char *v;
uchar *d, h[4];
- int sz, numtags, i, npages;
+ int sz, numtags, i, npages, pgend;
d = (uchar*)ctx->buf;
- for(npages = 0; npages < 2; npages++){
+ for(npages = pgend = 0; npages < 2; npages++){
int nsegs;
if(ctx->read(ctx, d, 27) != 27)
return -1;
@@ -28,6 +28,8 @@
ctx->channels = d[1];
ctx->samplerate = leuint(&d[4]);
}else if(memcmp(&d[nsegs], "OpusTags", 8) == 0){
+ /* FIXME - embedded pics make tags span multiple packets */
+ pgend = ctx->seek(ctx, 0, 1) + sz;
break;
}
@@ -47,6 +49,9 @@
return -1;
if((sz = leuint(h)) < 0)
return -1;
+ /* FIXME - embedded pics make tags span multiple packets */
+ if(pgend < ctx->seek(ctx, 0, 1)+sz)
+ break;
if(ctx->bufsz < sz+1){
if(ctx->seek(ctx, sz, 1) < 0)
--- a/vorbis.c
+++ b/vorbis.c
@@ -37,11 +37,11 @@
{
char *v;
uchar *d, h[4];
- int sz, numtags, i, npages;
+ int sz, numtags, i, npages, pgend;
d = (uchar*)ctx->buf;
/* need to find vorbis frame with type=3 */
- for(npages = 0; npages < 2; npages++){ /* vorbis comment is the second header */
+ for(npages = pgend = 0; npages < 2; npages++){ /* vorbis comment is the second header */
int nsegs;
if(ctx->read(ctx, d, 27) != 27)
return -1;
@@ -54,8 +54,11 @@
return -1;
for(sz = i = 0; i < nsegs; sz += d[i++]);
- if(d[nsegs] == 3) /* comment */
+ if(d[nsegs] == 3){ /* comment */
+ /* FIXME - embedded pics make tags span multiple packets */
+ pgend = ctx->seek(ctx, 0, 1) + sz;
break;
+ }
if(d[nsegs] == 1 && sz >= 28){ /* identification */
if(ctx->read(ctx, d, 28) != 28)
return -1;
@@ -82,6 +85,9 @@
return -1;
if((sz = leuint(h)) < 0)
return -1;
+ /* FIXME - embedded pics make tags span multiple packets */
+ if(pgend < ctx->seek(ctx, 0, 1)+sz)
+ break;
if(ctx->bufsz < sz+1){
if(ctx->seek(ctx, sz, 1) < 0)