[libav-devel] [PATCH 1/2] smacker: add sanity check for length in smacker_decode_tree()

Sean McGovern gseanmcg at gmail.com
Wed Nov 8 03:24:42 CET 2017


From: Michael Niedermayer <michaelni at gmx.at>

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

Bug-Id: 1098
Cc: libav-stable at libav.org
Signed-off-by: Sean McGovern <gseanmcg at gmail.com>
---
 libavcodec/smacker.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c
index 0e057a1..e829405 100644
--- a/libavcodec/smacker.c
+++ b/libavcodec/smacker.c
@@ -97,6 +97,11 @@ enum SmkBlockTypes {
 static int smacker_decode_tree(BitstreamContext *bc, HuffContext *hc,
                                uint32_t prefix, int length)
 {
+    if(length > 32) {
+        av_log(NULL, AV_LOG_ERROR, "length too long\n");
+        return AVERROR_INVALIDDATA;
+    }
+
     if (!bitstream_read_bit(bc)) { // Leaf
         if(hc->current >= 256){
             av_log(NULL, AV_LOG_ERROR, "Tree size exceeded!\n");
-- 
2.7.4



More information about the libav-devel mailing list