[Spice-devel] server/red_worker: handle_dev_update_area: fail if invalid area

Submitted by Alon Levy on July 29, 2012, 9:54 a.m.

Details

Message ID 1343555671-3529-1-git-send-email-alevy@redhat.com
State Accepted
Commit e7aee13e571662f9af87ef90533aa77c754d7747
Headers show

Not browsing as part of any series.

Commit Message

Alon Levy July 29, 2012, 9:54 a.m.
---
 server/red_worker.c | 6 ++++++
 1 file changed, 6 insertions(+)

Patch hide | download patch | download mbox

diff --git a/server/red_worker.c b/server/red_worker.c
index 9009462..eb21208 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -4589,6 +4589,12 @@  static void red_update_area(RedWorker *worker, const SpiceRect *area, int surfac
 #endif
     spice_debug("surface %d: area ==>", surface_id);
     rect_debug(area);
+
+    spice_return_if_fail(surface_id >= 0 && surface_id < NUM_SURFACES);
+    spice_return_if_fail(area);
+    spice_return_if_fail(area->left >= 0 && area->top >= 0 &&
+                         area->left < area->right && area->top < area->bottom);
+
     surface = &worker->surfaces[surface_id];
 
     last = NULL;

Comments

ACK.

On 07/29/2012 11:54 AM, Alon Levy wrote:
> ---
>   server/red_worker.c | 6 ++++++
>   1 file changed, 6 insertions(+)
>
> diff --git a/server/red_worker.c b/server/red_worker.c
> index 9009462..eb21208 100644
> --- a/server/red_worker.c
> +++ b/server/red_worker.c
> @@ -4589,6 +4589,12 @@ static void red_update_area(RedWorker *worker, const SpiceRect *area, int surfac
>   #endif
>       spice_debug("surface %d: area ==>", surface_id);
>       rect_debug(area);
> +
> +    spice_return_if_fail(surface_id >= 0 && surface_id < NUM_SURFACES);
> +    spice_return_if_fail(area);
> +    spice_return_if_fail(area->left >= 0 && area->top >= 0 &&
> +                         area->left < area->right && area->top < area->bottom);
> +
>       surface = &worker->surfaces[surface_id];
>
>       last = NULL;
>