This is an automated email from the git hooks/post-receive script.
Git pushed a commit to branch master
in repository ffmpeg.
The following commit(s) were added to refs/heads/master by this push:
new 5bbc00c05d [Wave] Fix issues with unaligned metadata chunks.
5bbc00c05d is described below
commit 5bbc00c05d6e78542d09bb56c55759ce6b53c139
Author: Dale Curtis <[email protected]>
AuthorDate: Wed Apr 22 23:46:14 2026 +0000
Commit: Daniel Verkamp <[email protected]>
CommitDate: Sun May 10 01:18:09 2026 +0000
[Wave] Fix issues with unaligned metadata chunks.
Fixes corruption issues with the sample in this PR.
Signed-off-by: Dale Curtis <[email protected]>
---
libavformat/wavdec.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
index f56f9d5c59..b980bebf0e 100644
--- a/libavformat/wavdec.c
+++ b/libavformat/wavdec.c
@@ -131,11 +131,11 @@ static int64_t next_tag(AVIOContext *pb, uint32_t *tag,
int big_endian)
}
/* RIFF chunks are always at even offsets relative to where they start. */
-static int64_t wav_seek_tag(WAVDemuxContext * wav, AVIOContext *s, int64_t
offset, int whence)
+static int64_t wav_seek_tag(WAVDemuxContext * wav, AVIOContext *s, int64_t
offset)
{
offset += offset < INT64_MAX && offset + wav->unaligned & 1;
- return avio_seek(s, offset, whence);
+ return avio_seek(s, offset, SEEK_SET);
}
/* return the size of the found tag */
@@ -144,13 +144,16 @@ static int64_t find_tag(WAVDemuxContext * wav,
AVIOContext *pb, uint32_t tag1)
unsigned int tag;
int64_t size;
+ if (avio_tell(pb) + wav->unaligned & 1)
+ avio_skip(pb, 1);
+
for (;;) {
if (avio_feof(pb))
return AVERROR_EOF;
size = next_tag(pb, &tag, wav->rifx);
if (tag == tag1)
break;
- wav_seek_tag(wav, pb, size, SEEK_CUR);
+ avio_skip(pb, size + (size & 1));
}
return size;
}
@@ -422,7 +425,7 @@ static int wav_read_header(AVFormatContext *s)
for (;;) {
AVStream *vst;
size = next_tag(pb, &tag, wav->rifx);
- next_tag_ofs = avio_tell(pb) + size;
+ next_tag_ofs = avio_tell(pb) + size + (size & 1);
if (avio_feof(pb))
break;
@@ -454,10 +457,12 @@ static int wav_read_header(AVFormatContext *s)
}
if (rf64 || bw64) {
- next_tag_ofs = wav->data_end = av_sat_add64(avio_tell(pb),
data_size);
- } else if (size != 0xFFFFFFFF) {
+ wav->data_end = av_sat_add64(avio_tell(pb), data_size);
+ next_tag_ofs = wav->data_end + (data_size & 1);
+ } else if (size > 0 && size != 0xFFFFFFFF) {
data_size = size;
- next_tag_ofs = wav->data_end = size ? next_tag_ofs : INT64_MAX;
+ wav->data_end = avio_tell(pb) + size;
+ next_tag_ofs = wav->data_end + (size & 1);
} else {
av_log(s, AV_LOG_WARNING, "Ignoring maximum wav data size, "
"file may be invalid\n");
@@ -599,7 +604,7 @@ static int wav_read_header(AVFormatContext *s)
/* seek to next tag unless we know that we'll run into EOF */
if ((avio_size(pb) > 0 && next_tag_ofs >= avio_size(pb)) ||
- wav_seek_tag(wav, pb, next_tag_ofs, SEEK_SET) < 0) {
+ wav_seek_tag(wav, pb, next_tag_ofs) < 0) {
break;
}
}
_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]