[FFmpeg-devel,2/3] avcodec/rasc: Fix off by 1 error in vertical coordinate

Submitted by Michael Niedermayer on Oct. 2, 2018, 1:04 a.m.

Details

Message ID 20181002010452.12356-2-michael@niedermayer.cc
State New
Headers show

Commit Message

Michael Niedermayer Oct. 2, 2018, 1:04 a.m.
Fixes: out of array read
Fixes: 10311/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RASC_fuzzer-4856330905452544

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

Comments

Michael Niedermayer Oct. 2, 2018, 1:10 a.m.
On Tue, Oct 02, 2018 at 03:04:51AM +0200, Michael Niedermayer wrote:
> Fixes: out of array read
> Fixes: 10311/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RASC_fuzzer-4856330905452544
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/rasc.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

btw, i found no file that uses this codepath, if someone has some RASC files
please share a link so i can test this

thx

[...]
Paul B Mahol Oct. 2, 2018, 7:52 a.m.
On 10/2/18, Michael Niedermayer <michael@niedermayer.cc> wrote:
> Fixes: out of array read
> Fixes:
> 10311/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RASC_fuzzer-4856330905452544
>
> Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---

LGTM

Patch hide | download patch | download mbox

diff --git a/libavcodec/rasc.c b/libavcodec/rasc.c
index fbbb134f4b..eb021681c6 100644
--- a/libavcodec/rasc.c
+++ b/libavcodec/rasc.c
@@ -272,9 +272,9 @@  static int decode_move(AVCodecContext *avctx,
         if (!s->frame2->data[0] || !s->frame1->data[0])
             return AVERROR_INVALIDDATA;
 
-        b1 = s->frame1->data[0] + s->frame1->linesize[0] * (start_y + h) + start_x * s->bpp;
-        b2 = s->frame2->data[0] + s->frame2->linesize[0] * (start_y + h) + start_x * s->bpp;
-        e2 = s->frame2->data[0] + s->frame2->linesize[0] * (mov_y + h) + mov_x * s->bpp;
+        b1 = s->frame1->data[0] + s->frame1->linesize[0] * (start_y + h - 1) + start_x * s->bpp;
+        b2 = s->frame2->data[0] + s->frame2->linesize[0] * (start_y + h - 1) + start_x * s->bpp;
+        e2 = s->frame2->data[0] + s->frame2->linesize[0] * (mov_y + h - 1) + mov_x * s->bpp;
 
         if (type == 2) {
             for (int j = 0; j < h; j++) {