Mercurial > libavcodec.hg
comparison vorbis_dec.c @ 10250:6e01bba7a930 libavcodec
Check begin/end/partition_size.
23_vorbis_sane_partition.patch by chrome.
Also this should be better documented but i prefer not to leave potential
security issues open due to missing documentation.
author | michael |
---|---|
date | Wed, 23 Sep 2009 13:08:48 +0000 |
parents | d82fb1889446 |
children | b9ea1706bf27 |
comparison
equal
deleted
inserted
replaced
10249:e56302a77ca9 | 10250:6e01bba7a930 |
---|---|
35 #include "xiph.h" | 35 #include "xiph.h" |
36 | 36 |
37 #define V_NB_BITS 8 | 37 #define V_NB_BITS 8 |
38 #define V_NB_BITS2 11 | 38 #define V_NB_BITS2 11 |
39 #define V_MAX_VLCS (1<<16) | 39 #define V_MAX_VLCS (1<<16) |
40 #define V_MAX_PARTITIONS (1<<20) | |
40 | 41 |
41 #ifndef V_DEBUG | 42 #ifndef V_DEBUG |
42 #define AV_DEBUG(...) | 43 #define AV_DEBUG(...) |
43 #endif | 44 #endif |
44 | 45 |
636 AV_DEBUG(" %d. residue type %d \n", i, res_setup->type); | 637 AV_DEBUG(" %d. residue type %d \n", i, res_setup->type); |
637 | 638 |
638 res_setup->begin=get_bits(gb, 24); | 639 res_setup->begin=get_bits(gb, 24); |
639 res_setup->end=get_bits(gb, 24); | 640 res_setup->end=get_bits(gb, 24); |
640 res_setup->partition_size=get_bits(gb, 24)+1; | 641 res_setup->partition_size=get_bits(gb, 24)+1; |
642 /* Validations to prevent a buffer overflow later. */ | |
643 if (res_setup->begin>res_setup->end | |
644 || res_setup->end>vc->blocksize[1]/(res_setup->type==2?1:2) | |
645 || (res_setup->end-res_setup->begin)/res_setup->partition_size>V_MAX_PARTITIONS) { | |
646 av_log(vc->avccontext, AV_LOG_ERROR, "partition out of bounds: type, begin, end, size, blocksize: %d, %d, %d, %d, %d\n", res_setup->type, res_setup->begin, res_setup->end, res_setup->partition_size, vc->blocksize[1]/2); | |
647 return 1; | |
648 } | |
649 | |
641 res_setup->classifications=get_bits(gb, 6)+1; | 650 res_setup->classifications=get_bits(gb, 6)+1; |
642 res_setup->classbook=get_bits(gb, 8); | 651 res_setup->classbook=get_bits(gb, 8); |
643 if (res_setup->classbook>=vc->codebook_count) { | 652 if (res_setup->classbook>=vc->codebook_count) { |
644 av_log(vc->avccontext, AV_LOG_ERROR, "classbook value %d out of range. \n", res_setup->classbook); | 653 av_log(vc->avccontext, AV_LOG_ERROR, "classbook value %d out of range. \n", res_setup->classbook); |
645 return 1; | 654 return 1; |