History

h264: reject mismatching luma/chroma bit depths during sps parsing

There is no point in delaying the check and it avoids bugs with a half-initialized context. Fixes invalid reads.

Anton Khirnov committed 12 years ago

Commit bfd26b71 parent 9a026c72 files · +5 −6Browse files

Unified · Split

2 files
  1. libavcodec/h264.c +0 −6
  2. libavcodec/h264_ps.c +5 −0
libavcodec/h264.c+0−6
@@ -3053,12 +3053,6 @@ static int h264_set_parameter_from_sps(H264Context *h) · 3052 unmodified lines
30533053 if (h->avctx->has_b_frames < 2)
30543054 h->avctx->has_b_frames = !h->low_delay;
30553055
3056− if (h->sps.bit_depth_luma != h->sps.bit_depth_chroma) {
3057− avpriv_request_sample(h->avctx,
3058− "Different chroma and luma bit depth");
3059− return AVERROR_PATCHWELCOME;
3060− }
3061−
30623056 if (h->avctx->bits_per_raw_sample != h->sps.bit_depth_luma ||
30633057 h->cur_chroma_format_idc != h->sps.chroma_format_idc) {
30643058 if (h->sps.bit_depth_luma >= 8 && h->sps.bit_depth_luma <= 10) {
libavcodec/h264_ps.c+5−0
@@ -341,6 +341,11 @@ int ff_h264_decode_seq_parameter_set(H264Context *h) · 340 unmodified lines
341341 }
342342 sps->bit_depth_luma = get_ue_golomb(&h->gb) + 8;
343343 sps->bit_depth_chroma = get_ue_golomb(&h->gb) + 8;
344+ if (sps->bit_depth_chroma != sps->bit_depth_luma) {
345+ avpriv_request_sample(h->avctx,
346+ "Different chroma and luma bit depth");
347+ goto fail;
348+ }
344349 sps->transform_bypass = get_bits1(&h->gb);
345350 decode_scaling_matrices(h, sps, NULL, 1,
346351 sps->scaling_matrix4, sps->scaling_matrix8);

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