diff mbox

[FFmpeg-devel] avcodec/cngdec: Fix integer clipping

Message ID 20171102173409.31224-1-michael@niedermayer.cc
State Accepted
Commit 51090133b31bc719ea868db15d3ee38e9dbe90f1
Headers show

Commit Message

Michael Niedermayer Nov. 2, 2017, 5:34 p.m. UTC
Fixes: runtime error: value -36211.7 is outside the range of representable values of type 'short'
Fixes: 2992/clusterfuzz-testcase-6649611793989632

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/cngdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Michael Niedermayer Nov. 8, 2017, 8:24 p.m. UTC | #1
On Thu, Nov 02, 2017 at 06:34:09PM +0100, Michael Niedermayer wrote:
> Fixes: runtime error: value -36211.7 is outside the range of representable values of type 'short'
> Fixes: 2992/clusterfuzz-testcase-6649611793989632
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/cngdec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

applied


[...]
diff mbox

Patch

diff --git a/libavcodec/cngdec.c b/libavcodec/cngdec.c
index 1e884f3c33..28432ac719 100644
--- a/libavcodec/cngdec.c
+++ b/libavcodec/cngdec.c
@@ -153,7 +153,7 @@  static int cng_decode_frame(AVCodecContext *avctx, void *data,
         return ret;
     buf_out = (int16_t *)frame->data[0];
     for (i = 0; i < avctx->frame_size; i++)
-        buf_out[i] = p->filter_out[i + p->order];
+        buf_out[i] = av_clip_int16(p->filter_out[i + p->order]);
     memcpy(p->filter_out, p->filter_out + avctx->frame_size,
            p->order * sizeof(*p->filter_out));