mirror of
https://gitee.com/openharmony/third_party_ffmpeg
synced 2025-01-07 20:01:56 +00:00
smacker: add sanity check for length in smacker_decode_tree()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at> Bug-Id: 1098 Cc: libav-stable@libav.org Signed-off-by: Sean McGovern <gseanmcg@gmail.com>
This commit is contained in:
parent
17b6c7efb4
commit
cd4663dc80
@ -43,7 +43,7 @@
|
|||||||
|
|
||||||
#define SMKTREE_BITS 9
|
#define SMKTREE_BITS 9
|
||||||
#define SMK_NODE 0x80000000
|
#define SMK_NODE 0x80000000
|
||||||
|
#define SMKTREE_DECODE_MAX_RECURSION 32
|
||||||
|
|
||||||
typedef struct SmackVContext {
|
typedef struct SmackVContext {
|
||||||
AVCodecContext *avctx;
|
AVCodecContext *avctx;
|
||||||
@ -97,6 +97,11 @@ enum SmkBlockTypes {
|
|||||||
static int smacker_decode_tree(BitstreamContext *bc, HuffContext *hc,
|
static int smacker_decode_tree(BitstreamContext *bc, HuffContext *hc,
|
||||||
uint32_t prefix, int length)
|
uint32_t prefix, int length)
|
||||||
{
|
{
|
||||||
|
if (length > SMKTREE_DECODE_MAX_RECURSION) {
|
||||||
|
av_log(NULL, AV_LOG_ERROR, "Maximum tree recursion level exceeded.\n");
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
|
|
||||||
if (!bitstream_read_bit(bc)) { // Leaf
|
if (!bitstream_read_bit(bc)) { // Leaf
|
||||||
if(hc->current >= 256){
|
if(hc->current >= 256){
|
||||||
av_log(NULL, AV_LOG_ERROR, "Tree size exceeded!\n");
|
av_log(NULL, AV_LOG_ERROR, "Tree size exceeded!\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user