diff mbox series

[FFmpeg-devel,3/5] avcodec/012v: Order operations for odd size handling

Message ID 20230113000138.9994-3-michael@niedermayer.cc
State Accepted
Commit 4d42d82563d806b5610c0c91497e24ef7f37d4cf
Headers show
Series [FFmpeg-devel,1/5] avcodec/wbmpdec: use remaining size not whole size | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished

Commit Message

Michael Niedermayer Jan. 13, 2023, 12:01 a.m. UTC
Fixes: out of array access
Fixes: 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ZERO12V_fuzzer-6714182078955520.fuzz
Fixes: 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ZERO12V_fuzzer-6698145212137472.fuzz

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

Comments

Paul B Mahol Jan. 16, 2023, 8:19 a.m. UTC | #1
On 1/13/23, Michael Niedermayer <michael@niedermayer.cc> wrote:
> Fixes: out of array access
> Fixes:
> 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ZERO12V_fuzzer-6714182078955520.fuzz
> Fixes:
> 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ZERO12V_fuzzer-6698145212137472.fuzz
>
> Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/012v.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/012v.c b/libavcodec/012v.c
> index 2d89a86b98..f0197cd8f9 100644
> --- a/libavcodec/012v.c
> +++ b/libavcodec/012v.c
> @@ -131,8 +131,8 @@ static int zero12v_decode_frame(AVCodecContext *avctx,
> AVFrame *pic,
>              u = x/2 + (uint16_t *)(pic->data[1] + line *
> pic->linesize[1]);
>              v = x/2 + (uint16_t *)(pic->data[2] + line *
> pic->linesize[2]);
>              memcpy(y, y_temp, sizeof(*y) * (width - x));
> -            memcpy(u, u_temp, sizeof(*u) * (width - x + 1) / 2);
> -            memcpy(v, v_temp, sizeof(*v) * (width - x + 1) / 2);
> +            memcpy(u, u_temp, sizeof(*u) * ((width - x + 1) / 2));
> +            memcpy(v, v_temp, sizeof(*v) * ((width - x + 1) / 2));
>          }
>
>          line_end += stride;
> --
> 2.17.1
>


LGTM

> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
diff mbox series

Patch

diff --git a/libavcodec/012v.c b/libavcodec/012v.c
index 2d89a86b98..f0197cd8f9 100644
--- a/libavcodec/012v.c
+++ b/libavcodec/012v.c
@@ -131,8 +131,8 @@  static int zero12v_decode_frame(AVCodecContext *avctx, AVFrame *pic,
             u = x/2 + (uint16_t *)(pic->data[1] + line * pic->linesize[1]);
             v = x/2 + (uint16_t *)(pic->data[2] + line * pic->linesize[2]);
             memcpy(y, y_temp, sizeof(*y) * (width - x));
-            memcpy(u, u_temp, sizeof(*u) * (width - x + 1) / 2);
-            memcpy(v, v_temp, sizeof(*v) * (width - x + 1) / 2);
+            memcpy(u, u_temp, sizeof(*u) * ((width - x + 1) / 2));
+            memcpy(v, v_temp, sizeof(*v) * ((width - x + 1) / 2));
         }
 
         line_end += stride;