Browse Source

avcodec/g2meet: Change order of operations to avoid undefined behavior

Fixes: signed integer overflow: 65280 * 196032 cannot be represented in type 'int'
Fixes: 7279/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_G2M_fuzzer-5977332473921536

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 0a47451458)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
tags/n2.8.15
Michael Niedermayer 7 years ago
parent
commit
02f4e846d2
1 changed files with 5 additions and 3 deletions
  1. +5
    -3
      libavcodec/g2meet.c

+ 5
- 3
libavcodec/g2meet.c View File

@@ -1355,14 +1355,16 @@ static void g2m_paint_cursor(G2MContext *c, uint8_t *dst, int stride)
} else {
dst += x * 3;
}
if (y < 0) {

if (y < 0)
h += y;
if (w < 0 || h < 0)
return;
if (y < 0) {
cursor += -y * c->cursor_stride;
} else {
dst += y * stride;
}
if (w < 0 || h < 0)
return;

for (j = 0; j < h; j++) {
for (i = 0; i < w; i++) {


Loading…
Cancel
Save