History

avcodec/hevc_ps: add proper bound checks around cm_ref_layer_id in colour_mapping_table.

Clement Lecigne committed 3 years ago

Commit 96c30af1 parent 84505312 files · +17 −7Browse files

Showing the changes to libavcodec (2 of 2 files). Show all

Unified · Split

2 files
  1. libavcodec/hevc_ps.c +15 −5
  2. libavcodec/hevc_ps.h +2 −2
libavcodec/hevc_ps.c+15−5
@@ -1374,10 +1374,15 @@ static void colour_mapping_octants(GetBitContext *gb, HEVCPPS *pps, int inp_dept · 1373 unmodified lines
1374 }1374 }
1375}1375}
1376 1376
1377static void colour_mapping_table(GetBitContext *gb, HEVCPPS *pps)1377static int colour_mapping_table(GetBitContext *gb, AVCodecContext *avctx, HEVCPPS *pps)
1378{1378{
1379 pps->num_cm_ref_layers_minus1 = get_ue_golomb_long(gb);1379 pps->num_cm_ref_layers = get_ue_golomb(gb) + 1;
1380 for (int i = 0; i <= pps->num_cm_ref_layers_minus1; i++)1380 if (pps->num_cm_ref_layers > 62) {
1381 av_log(avctx, AV_LOG_ERROR,
1382 "num_cm_ref_layers_minus1 shall be in the range [0, 61].\n");
1383 return AVERROR_INVALIDDATA;
1384 }
1385 for (int i = 0; i < pps->num_cm_ref_layers; i++)
1381 pps->cm_ref_layer_id[i] = get_bits(gb, 6);1386 pps->cm_ref_layer_id[i] = get_bits(gb, 6);
1382 1387
1383 pps->cm_octant_depth = get_bits(gb, 2);1388 pps->cm_octant_depth = get_bits(gb, 2);
@@ -1397,6 +1402,8 @@ static void colour_mapping_table(GetBitContext *gb, HEVCPPS *pps) · 13 unmodified lines
1397 }1402 }
1398 1403
1399 colour_mapping_octants(gb, pps, 0, 0, 0, 0, 1 << pps->cm_octant_depth);1404 colour_mapping_octants(gb, pps, 0, 0, 0, 0, 1 << pps->cm_octant_depth);
1405
1406 return 0;
1400}1407}
1401 1408
1402static int pps_multilayer_extension(GetBitContext *gb, AVCodecContext *avctx,1409static int pps_multilayer_extension(GetBitContext *gb, AVCodecContext *avctx,
@@ -1439,8 +1446,11 @@ static int pps_multilayer_extension(GetBitContext *gb, AVCodecContext *avctx, · 36 unmodified lines
1439 }1446 }
1440 1447
1441 pps->colour_mapping_enabled_flag = get_bits1(gb);1448 pps->colour_mapping_enabled_flag = get_bits1(gb);
1442 if (pps->colour_mapping_enabled_flag)1449 if (pps->colour_mapping_enabled_flag) {
1443 colour_mapping_table(gb, pps);1450 int ret = colour_mapping_table(gb, avctx, pps);
1451 if (ret < 0)
1452 return ret;
1453 }
1444 1454
1445 return 0;1455 return 0;
1446}1456}
libavcodec/hevc_ps.h+2−2
@@ -332,8 +332,8 @@ typedef struct HEVCPPS { · 331 unmodified lines
332 int8_t phase_hor_chroma[64];332 int8_t phase_hor_chroma[64];
333 int8_t phase_ver_chroma[64];333 int8_t phase_ver_chroma[64];
334 uint8_t colour_mapping_enabled_flag;334 uint8_t colour_mapping_enabled_flag;
335 uint16_t num_cm_ref_layers_minus1;335 uint8_t num_cm_ref_layers;
336 uint8_t cm_ref_layer_id[63];336 uint8_t cm_ref_layer_id[62];
337 uint8_t cm_octant_depth;337 uint8_t cm_octant_depth;
338 uint8_t cm_y_part_num_log2;338 uint8_t cm_y_part_num_log2;
339 uint8_t luma_bit_depth_cm_input;339 uint8_t luma_bit_depth_cm_input;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t