[FFmpeg-devel] [PATCH 1/2] avformat/westwood_audenc: Check for, not assert on invalid data
Andreas Rheinhardt
andreas.rheinhardt at outlook.com
Mon Apr 26 16:01:26 EEST 2021
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
Is pkt->size * 4 actually supposed to be the size of audio after
decoding? If so, the factor four would have to be changed to two
for files flagged as 8 bit.
(The 8/16 bit check seems broken; my actual intention with not
unconditionally flagging the file as 16 bit was that remuxing content
flagged as 8 bit should work, but it doesn't, because the current check
only checks for the codec_id.)
libavformat/westwood_audenc.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libavformat/westwood_audenc.c b/libavformat/westwood_audenc.c
index 4ec905b088..490f2ee260 100644
--- a/libavformat/westwood_audenc.c
+++ b/libavformat/westwood_audenc.c
@@ -103,7 +103,8 @@ static int wsaud_write_packet(AVFormatContext *ctx, AVPacket *pkt)
AVIOContext *pb = ctx->pb;
AUDMuxContext *a = ctx->priv_data;
- av_assert1(pkt->size < UINT16_MAX && (pkt->size * 4) < UINT16_MAX);
+ if (pkt->size > UINT16_MAX / 4)
+ return AVERROR_INVALIDDATA;
/* Assumes ADPCM since this muxer doesn't support SND1 or PCM format. */
avio_wl16(pb, pkt->size);
avio_wl16(pb, pkt->size * 4);
--
2.27.0
More information about the ffmpeg-devel
mailing list