[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 1/8] vnc-enc-tight: Fix divide-by-zero in tight_dete
From: |
arei.gonglei |
Subject: |
[Qemu-devel] [PATCH 1/8] vnc-enc-tight: Fix divide-by-zero in tight_detect_smooth_image{16, 24, 32} |
Date: |
Tue, 27 May 2014 09:39:58 +0800 |
From: Gonglei <address@hidden>
Spotted by Coverity:
(1) Event assignment: Assigning: "pixels" = "0".
(2) Event cond_true: Condition "y < h", taking true branch
(3) Event cond_false: Condition "x < w", taking false branch
(4) Event loop_end: Reached end of loop
(5) Event divide_by_zero: In expression "(stats[0] + stats[1]) * 100U /
pixels",
division by expression "pixels" which may be zero has undefined behavior.
290 DEFINE_DETECT_FUNCTION(16)
291 DEFINE_DETECT_FUNCTION(32)
Signed-off-by: Gonglei <address@hidden>
---
ui/vnc-enc-tight.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/ui/vnc-enc-tight.c b/ui/vnc-enc-tight.c
index 59b59c0..f02352c 100644
--- a/ui/vnc-enc-tight.c
+++ b/ui/vnc-enc-tight.c
@@ -181,6 +181,10 @@ tight_detect_smooth_image24(VncState *vs, int w, int h)
}
}
+ if (pixels == 0) {
+ return 0;
+ }
+
/* 95% smooth or more ... */
if (stats[0] * 33 / pixels >= 95) {
return 0;
@@ -267,7 +271,9 @@ tight_detect_smooth_image24(VncState *vs, int w, int h)
y += w; \
} \
} \
- \
+ if (pixels == 0) { \
+ return 0; \
+ } \
if ((stats[0] + stats[1]) * 100 / pixels >= 90) { \
return 0; \
} \
--
1.7.12.4
- Re: [Qemu-devel] [PATCH 3/8] json-parser: fix two coverity defects, (continued)
Re: [Qemu-devel] [PATCH 6/8] smbus: Fix unreachable code in smb_transaction(), Eric Blake, 2014/05/28
[Qemu-devel] [PATCH 1/8] vnc-enc-tight: Fix divide-by-zero in tight_detect_smooth_image{16, 24, 32},
arei.gonglei <=
- Re: [Qemu-devel] [PATCH 1/8] vnc-enc-tight: Fix divide-by-zero in tight_detect_smooth_image{16, 24, 32}, Paolo Bonzini, 2014/05/27
- Re: [Qemu-devel] [PATCH 1/8] vnc-enc-tight: Fix divide-by-zero in tight_detect_smooth_image{16, 24, 32}, Gonglei (Arei), 2014/05/28
- Re: [Qemu-devel] [PATCH 1/8] vnc-enc-tight: Fix divide-by-zero in tight_detect_smooth_image{16, 24, 32}, Paolo Bonzini, 2014/05/28
- Re: [Qemu-devel] [PATCH 1/8] vnc-enc-tight: Fix divide-by-zero in tight_detect_smooth_image{16, 24, 32}, Gonglei (Arei), 2014/05/28
[Qemu-devel] [PATCH 8/8] audio: Fix using freed pointer in wav_fini_out(), arei.gonglei, 2014/05/26
[Qemu-devel] [PATCH 4/8] qcow2-cluster: Fix memory leak in copy_sectors, arei.gonglei, 2014/05/26
[Qemu-devel] [PATCH 5/8] qemu-bridge-helper: Fix fd leak in main(), arei.gonglei, 2014/05/26