diff mbox

[FFmpeg-devel,1/4] avcodec/utils: Use av_memcpy_backptr() in ff_color_frame()

Message ID 20190908213419.22293-1-michael@niedermayer.cc
State Accepted
Commit 340ab13504dddb71889f518983174d7bac7cfe96
Headers show

Commit Message

Michael Niedermayer Sept. 8, 2019, 9:34 p.m. UTC
Fixes: Timeout (191sec -> 53sec)
Fixes: 16908/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_H264_fuzzer-5711207859748864
Fixes: 10709/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_H264_fuzzer-5630617975259136

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

Comments

Michael Niedermayer Sept. 24, 2019, 1:31 p.m. UTC | #1
On Sun, Sep 08, 2019 at 11:34:16PM +0200, Michael Niedermayer wrote:
> Fixes: Timeout (191sec -> 53sec)
> Fixes: 16908/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_H264_fuzzer-5711207859748864
> Fixes: 10709/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_H264_fuzzer-5630617975259136
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/utils.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

will apply patchset

[...]
diff mbox

Patch

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index a6a646636d..132f887343 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -412,7 +412,7 @@  int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels,
 void ff_color_frame(AVFrame *frame, const int c[4])
 {
     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format);
-    int p, y, x;
+    int p, y;
 
     av_assert0(desc->flags & AV_PIX_FMT_FLAG_PLANAR);
 
@@ -423,8 +423,8 @@  void ff_color_frame(AVFrame *frame, const int c[4])
         int height = is_chroma ? AV_CEIL_RSHIFT(frame->height, desc->log2_chroma_h) : frame->height;
         for (y = 0; y < height; y++) {
             if (desc->comp[0].depth >= 9) {
-                for (x = 0; x<bytes; x++)
-                    ((uint16_t*)dst)[x] = c[p];
+                ((uint16_t*)dst)[0] = c[p];
+                av_memcpy_backptr(dst + 2, 2, bytes - 2);
             }else
                 memset(dst, c[p], bytes);
             dst += frame->linesize[p];