[Spice-devel] [PATCH spice-gtk 07/15] Fix some integer range checks which always evaluate false
Daniel P. Berrange
berrange at redhat.com
Tue Mar 13 06:40:05 PDT 2012
From: "Daniel P. Berrange" <berrange at redhat.com>
There are some integer range checks which always evaluate false
due to use of unsigned integer types. One of these would prevent
detection of encoding errors from celt. The others are simply
no-ops.
* gtk/channel-record.c: Make 'frame_size' signed to allow detection
of celt encoding errors
* gtk/spicy.c: nkeys is an unsigned type, so checks for nkeys < 0 are bogus
* common/pixman_utils.c: SpiceROP is an enum & thus unsigned
---
common/pixman_utils.c | 4 ++--
gtk/channel-record.c | 3 ++-
gtk/spicy.c | 1 -
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/common/pixman_utils.c b/common/pixman_utils.c
index e1eec41..914c97e 100644
--- a/common/pixman_utils.c
+++ b/common/pixman_utils.c
@@ -315,7 +315,7 @@ void spice_pixman_fill_rect_rop(pixman_image_t *dest,
ASSERT(height > 0);
ASSERT(x + width <= pixman_image_get_width(dest));
ASSERT(y + height <= pixman_image_get_height(dest));
- ASSERT(rop >= 0 && rop < 16);
+ ASSERT(rop < 16);
if (depth == 8) {
solid_rop_8_func_t rop_func = solid_rops_8[rop];
@@ -466,7 +466,7 @@ void spice_pixman_tile_rect_rop(pixman_image_t *dest,
ASSERT(height > 0);
ASSERT(x + width <= pixman_image_get_width(dest));
ASSERT(y + height <= pixman_image_get_height(dest));
- ASSERT(rop >= 0 && rop < 16);
+ ASSERT(rop < 16);
ASSERT(depth == spice_pixman_image_get_bpp(tile));
tile_start_x = (x - offset_x) % tile_width;
diff --git a/gtk/channel-record.c b/gtk/channel-record.c
index c5aded9..fba385b 100644
--- a/gtk/channel-record.c
+++ b/gtk/channel-record.c
@@ -375,7 +375,8 @@ void spice_record_send_data(SpiceRecordChannel *channel, gpointer data,
p.time = time;
while (bytes > 0) {
- gsize n, frame_size;
+ gsize n;
+ int frame_size;
SpiceMsgOut *msg;
uint8_t *frame;
diff --git a/gtk/spicy.c b/gtk/spicy.c
index 8e9d051..b5b6e1d 100644
--- a/gtk/spicy.c
+++ b/gtk/spicy.c
@@ -626,7 +626,6 @@ static void restore_configuration(struct spice_window *win)
return;
}
- g_return_if_fail(nkeys >= 0);
if (nkeys > 0)
g_return_if_fail(keys != NULL);
--
1.7.7.6
More information about the Spice-devel
mailing list