diff mbox

[FFmpeg-devel,1/3] avcodec/cbs_av1_syntax_template: Check num_y_points

Message ID 20191211210352.1022-1-michael@niedermayer.cc
State New
Headers show

Commit Message

Michael Niedermayer Dec. 11, 2019, 9:03 p.m. UTC
"It is a requirement of bitstream conformance that num_y_points is less than or equal to 14."

Fixes: index 24 out of bounds for type 'uint8_t [24]'
Fixes: 19282/clusterfuzz-testcase-minimized-ffmpeg_BSF_AV1_FRAME_MERGE_fuzzer-5747424845103104

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/cbs_av1_syntax_template.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

James Almer Dec. 11, 2019, 9:45 p.m. UTC | #1
On 12/11/2019 6:03 PM, Michael Niedermayer wrote:
> "It is a requirement of bitstream conformance that num_y_points is less than or equal to 14."
> 
> Fixes: index 24 out of bounds for type 'uint8_t [24]'
> Fixes: 19282/clusterfuzz-testcase-minimized-ffmpeg_BSF_AV1_FRAME_MERGE_fuzzer-5747424845103104
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/cbs_av1_syntax_template.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/cbs_av1_syntax_template.c b/libavcodec/cbs_av1_syntax_template.c
> index 6c4816f964..5da54b695d 100644
> --- a/libavcodec/cbs_av1_syntax_template.c
> +++ b/libavcodec/cbs_av1_syntax_template.c
> @@ -1155,7 +1155,7 @@ static int FUNC(film_grain_params)(CodedBitstreamContext *ctx, RWContext *rw,
>          return 0;
>      }
>  
> -    fb(4, num_y_points);
> +    fc(4, num_y_points, 0, 14);
>      for (i = 0; i < current->num_y_points; i++) {
>          fbs(8, point_y_value[i],   1, i);
>          fbs(8, point_y_scaling[i], 1, i);

LGTM.

You could also while at it reduce point_y_value and point_y_scaling from
uint8_t[16] to uint8_t[14].
diff mbox

Patch

diff --git a/libavcodec/cbs_av1_syntax_template.c b/libavcodec/cbs_av1_syntax_template.c
index 6c4816f964..5da54b695d 100644
--- a/libavcodec/cbs_av1_syntax_template.c
+++ b/libavcodec/cbs_av1_syntax_template.c
@@ -1155,7 +1155,7 @@  static int FUNC(film_grain_params)(CodedBitstreamContext *ctx, RWContext *rw,
         return 0;
     }
 
-    fb(4, num_y_points);
+    fc(4, num_y_points, 0, 14);
     for (i = 0; i < current->num_y_points; i++) {
         fbs(8, point_y_value[i],   1, i);
         fbs(8, point_y_scaling[i], 1, i);