diff mbox series

[FFmpeg-devel,2/3] avcodec/hevcdec: do not memcpy into itself

Message ID 20230427183840.1015-2-michael@niedermayer.cc
State New
Headers show
Series [FFmpeg-devel,1/3] tools/target_dec_fuzzer: Adjust threshold for rka | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Michael Niedermayer April 27, 2023, 6:38 p.m. UTC
Iam not sure if this buffer setup is intended but if it occurs memcpy() cannot always
be used

Fixes: memcpy-param-overlap
Fixes: 58062/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-4717458841010176

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

Comments

Michael Niedermayer Sept. 7, 2023, 10:07 p.m. UTC | #1
On Thu, Apr 27, 2023 at 08:38:39PM +0200, Michael Niedermayer wrote:
> Iam not sure if this buffer setup is intended but if it occurs memcpy() cannot always
> be used
> 
> Fixes: memcpy-param-overlap
> Fixes: 58062/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-4717458841010176
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/hevcdec.c | 1 +
>  1 file changed, 1 insertion(+)

patch withdrawn, as this is not a complete fix of the issue

[...]
diff mbox series

Patch

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 0fa4fdd59d..1e590ec5d0 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -1542,6 +1542,7 @@  static void luma_mc_uni(HEVCLocalContext *lc, uint8_t *dst, ptrdiff_t dststride,
     src   += y_off * srcstride + (x_off * (1 << s->ps.sps->pixel_shift));
 
     if (x_off < QPEL_EXTRA_BEFORE || y_off < QPEL_EXTRA_AFTER ||
+        s->frame->data[0] == ref->data[0] ||
         x_off >= pic_width - block_w - QPEL_EXTRA_AFTER ||
         y_off >= pic_height - block_h - QPEL_EXTRA_AFTER) {
         const ptrdiff_t edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->ps.sps->pixel_shift;