[FFmpeg-devel] [PATCH 2/3] wavpackenc: report too small buffer
Christophe Gisquet
christophe.gisquet at gmail.com
Tue Aug 19 14:26:48 CEST 2014
bytestream2_* will not cause buffer overflow, but on the other hand,
it should be checked whether overflows have been prevented.
---
libavcodec/wavpackenc.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/libavcodec/wavpackenc.c b/libavcodec/wavpackenc.c
index 5b8973c..46c69a3 100644
--- a/libavcodec/wavpackenc.c
+++ b/libavcodec/wavpackenc.c
@@ -2813,6 +2813,11 @@ static int wavpack_encode_block(WavPackEncodeContext *s,
block_size = bytestream2_tell_p(&pb);
AV_WL32(out + 4, block_size - 8);
+ if (put_bits_left(&s->pb) <= 0) {
+ av_log(s->avctx, AV_LOG_ERROR, "Packet allocated too small\n");
+ return AVERROR_INVALIDDATA;
+ }
+
return block_size;
}
--
1.9.2.msysgit.0
More information about the ffmpeg-devel
mailing list