Hi,

2014-08-19 18:28 GMT+02:00 Christophe Gisquet <christophe.gisq...@gmail.com>:
> 2014-08-19 16:20 GMT+02:00 Nicolas George <geo...@nsup.org>:
>> IMHO, the correct error depends on how sure you are that a buffer too small
>> SHOULD not happen.
>>
>> If you are very sure, then av_assert0().
>
> That would be it: I'm sure that, if the condition occurs and the
> packet is written anyway, the file will be incorrect.

Anyway, that should never occur, so here's a version with av_assert0.

-- 
Christophe
From ae8998602fa0d9114a09291c4623a1609a5fcb8c Mon Sep 17 00:00:00 2001
From: Christophe Gisquet <christophe.gisq...@gmail.com>
Date: Tue, 19 Aug 2014 14:05:56 +0200
Subject: [PATCH] wavpackenc: assert on too small buffer

bytestream2_* will not cause buffer overflow, but in that case, this means
the allocation would be incorrect and the encoded result invalid. Therefore,
assert no overflow occurred.
---
 libavcodec/wavpackenc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/wavpackenc.c b/libavcodec/wavpackenc.c
index 005cf7c..3631a08 100644
--- a/libavcodec/wavpackenc.c
+++ b/libavcodec/wavpackenc.c
@@ -2813,6 +2813,8 @@ static int wavpack_encode_block(WavPackEncodeContext *s,
     block_size = bytestream2_tell_p(&pb);
     AV_WL32(out + 4, block_size - 8);
 
+    av_assert0(put_bits_left(&s->pb) > 0);
+
     return block_size;
 }
 
-- 
1.9.2.msysgit.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to