aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2018-05-04 18:16:08 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2018-06-15 22:31:13 +0200
commit2cffce26a7863e7909b0a52ef5465a4db247ab72 (patch)
treef418f8e5d0f4ad4d6c7c3fce31f585d581600618
parentc26e101654b518cda5d0c04fedf23607a2a4575b (diff)
downloadffmpeg-2cffce26a7863e7909b0a52ef5465a4db247ab72.tar.gz
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 0a4745145840d97619c424961c1b5c625dbf516c) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/g2meet.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/libavcodec/g2meet.c b/libavcodec/g2meet.c
index b409dae813..5edfb31560 100644
--- a/libavcodec/g2meet.c
+++ b/libavcodec/g2meet.c
@@ -1356,14 +1356,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++) {