diff options
author | Sigrid Solveig Haflínudóttir <sigrid@ftrv.se> | 2022-10-13 01:18:53 +0000 |
---|---|---|
committer | Sigrid Solveig Haflínudóttir <sigrid@ftrv.se> | 2022-10-13 01:18:53 +0000 |
commit | 916022699ac940621052521a69d3e7b530f537f4 (patch) | |
tree | 59f7f2c76887e719359fe7da676926817648b667 /sys/src/cmd/audio | |
parent | b4e31923d4c4d447eb5c5a9153f26f05a56c9d08 (diff) |
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.
Diffstat (limited to 'sys/src/cmd/audio')
-rw-r--r-- | sys/src/cmd/audio/libtags/opus.c | 9 | ||||
-rw-r--r-- | sys/src/cmd/audio/libtags/vorbis.c | 12 |
2 files changed, 16 insertions, 5 deletions
diff --git a/sys/src/cmd/audio/libtags/opus.c b/sys/src/cmd/audio/libtags/opus.c index 8b0b35dff..e846f66f1 100644 --- a/sys/src/cmd/audio/libtags/opus.c +++ b/sys/src/cmd/audio/libtags/opus.c @@ -5,10 +5,10 @@ tagopus(Tagctx *ctx) { 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 @@ tagopus(Tagctx *ctx) 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 @@ tagopus(Tagctx *ctx) 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) diff --git a/sys/src/cmd/audio/libtags/vorbis.c b/sys/src/cmd/audio/libtags/vorbis.c index 2c00d085b..bea8d8cc2 100644 --- a/sys/src/cmd/audio/libtags/vorbis.c +++ b/sys/src/cmd/audio/libtags/vorbis.c @@ -37,11 +37,11 @@ tagvorbis(Tagctx *ctx) { 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 @@ tagvorbis(Tagctx *ctx) 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 @@ tagvorbis(Tagctx *ctx) 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) |