debuggers.hg

changeset 22903:74cd0f668546

The current libxl_set_memory_target function subtracts a negative amount
from an uint32_t variable without checking if the operation wraps
around.

This patch fixes this bug (that I previously believed to be an
hypervisor issue):
http://bugzilla.xensource.com/bugzilla/show_bug.cgi?id=1729

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
author Stefano Stabellini <stefano.stabellini@eu.citrix.com>
date Tue Feb 01 19:25:08 2011 +0000 (2011-02-01)
parents 18807b89083d
children 9a6458e0c3f5
files tools/libxl/libxl.c
line diff
     1.1 --- a/tools/libxl/libxl.c	Tue Feb 01 19:23:31 2011 +0000
     1.2 +++ b/tools/libxl/libxl.c	Tue Feb 01 19:25:08 2011 +0000
     1.3 @@ -2059,9 +2059,12 @@ retry_transaction:
     1.4          goto out;
     1.5      }
     1.6  
     1.7 -    if (relative)
     1.8 -        new_target_memkb = current_target_memkb + target_memkb;
     1.9 -    else
    1.10 +    if (relative) {
    1.11 +        if (target_memkb < 0 && abs(target_memkb) > current_target_memkb)
    1.12 +            new_target_memkb = 0;
    1.13 +        else
    1.14 +            new_target_memkb = current_target_memkb + target_memkb;
    1.15 +    } else
    1.16          new_target_memkb = target_memkb;
    1.17      if (new_target_memkb > memorykb) {
    1.18          LIBXL__LOG(ctx, LIBXL__LOG_ERROR,