aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/h264_ps.c
diff options
context:
space:
mode:
authorJanne Grunau <janne-libav@jannau.net>2012-11-25 12:56:04 +0100
committerReinhard Tartler <siretart@tauware.de>2013-01-12 19:34:10 +0100
commit4457e6137d83d3b65d919608cd0f12bc62d57c67 (patch)
tree8aa46136ed9224f441f1977a415266a69e1aa396 /libavcodec/h264_ps.c
parent08d9fd611eac18be52e0bd3430ba6acb740cd79f (diff)
downloadffmpeg-4457e6137d83d3b65d919608cd0f12bc62d57c67.tar.gz
h264: check sps.log2_max_frame_num for validity
Fixes infinite or long taking loop in frame num gap code in the fuzzed sample bipbop234.ts_s223302. CC: libav-stable@libav.org (cherry picked from commit d7d6efe42b0d2057e67999b96b9a391f533d2333) Signed-off-by: Reinhard Tartler <siretart@tauware.de>
Diffstat (limited to 'libavcodec/h264_ps.c')
-rw-r--r--libavcodec/h264_ps.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/libavcodec/h264_ps.c b/libavcodec/h264_ps.c
index 9eeff59762..367138a8c0 100644
--- a/libavcodec/h264_ps.c
+++ b/libavcodec/h264_ps.c
@@ -37,6 +37,9 @@
//#undef NDEBUG
#include <assert.h>
+#define MAX_LOG2_MAX_FRAME_NUM (12 + 4)
+#define MIN_LOG2_MAX_FRAME_NUM 4
+
static const AVRational pixel_aspect[17]={
{0, 1},
{1, 1},
@@ -298,7 +301,7 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){
MpegEncContext * const s = &h->s;
int profile_idc, level_idc, constraint_set_flags = 0;
unsigned int sps_id;
- int i;
+ int i, log2_max_frame_num_minus4;
SPS *sps;
profile_idc= get_bits(&s->gb, 8);
@@ -345,7 +348,16 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){
sps->bit_depth_chroma = 8;
}
- sps->log2_max_frame_num= get_ue_golomb(&s->gb) + 4;
+ log2_max_frame_num_minus4 = get_ue_golomb(&s->gb);
+ if (log2_max_frame_num_minus4 < MIN_LOG2_MAX_FRAME_NUM - 4 ||
+ log2_max_frame_num_minus4 > MAX_LOG2_MAX_FRAME_NUM - 4) {
+ av_log(h->s.avctx, AV_LOG_ERROR,
+ "log2_max_frame_num_minus4 out of range (0-12): %d\n",
+ log2_max_frame_num_minus4);
+ return AVERROR_INVALIDDATA;
+ }
+ sps->log2_max_frame_num = log2_max_frame_num_minus4 + 4;
+
sps->poc_type= get_ue_golomb_31(&s->gb);
if(sps->poc_type == 0){ //FIXME #define