diff mbox

[FFmpeg-devel] avcodec/flacdec: Check for invalid vlcs

Message ID 20161209152935.3475-1-michael@niedermayer.cc
State Accepted
Commit fd00203554334f602ee1d7c5416ff25f356f4fb7
Headers show

Commit Message

Michael Niedermayer Dec. 9, 2016, 3:29 p.m. UTC
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/flacdec.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Michael Niedermayer Feb. 4, 2017, 1:15 a.m. UTC | #1
On Fri, Dec 09, 2016 at 04:29:35PM +0100, Michael Niedermayer wrote:
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/flacdec.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)

applied


[...]
diff mbox

Patch

diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c
index af81115ff8..0fffc2dd94 100644
--- a/libavcodec/flacdec.c
+++ b/libavcodec/flacdec.c
@@ -259,7 +259,13 @@  static int decode_residuals(FLACContext *s, int32_t *decoded, int pred_order)
                 *decoded++ = get_sbits_long(&s->gb, tmp);
         } else {
             for (; i < samples; i++) {
-                *decoded++ = get_sr_golomb_flac(&s->gb, tmp, INT_MAX, 0);
+                int v = get_sr_golomb_flac(&s->gb, tmp, INT_MAX, 0);
+                if (v == 0x80000000){
+                    av_log(s->avctx, AV_LOG_ERROR, "invalid residual\n");
+                    return AVERROR_INVALIDDATA;
+                }
+
+                *decoded++ = v;
             }
         }
         i= 0;