]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: fix a integer boundary error
authorGuannan Ren <gren@redhat.com>
Tue, 5 Mar 2013 15:13:21 +0000 (23:13 +0800)
committerGuannan Ren <gren@redhat.com>
Wed, 6 Mar 2013 03:46:33 +0000 (11:46 +0800)
A value which is equal to a integer maximum such as LLONG_MAX is
a valid integer value.

The patch fix the following error:
1, virsh memtune vm --swap-hard-limit -1
2, virsh start vm
In debug mode, it shows error like:
virScaleInteger:1813 : numerical overflow:\
                       value too large: 9007199254740991KiB

src/util/virutil.c

index 4af2599c55b61e0ad16ccbddeb3a098675a5d1cd..4605c78ca73a10896d02461aa65baa2805daf75e 100644 (file)
@@ -1809,7 +1809,7 @@ virScaleInteger(unsigned long long *value, const char *suffix,
         }
     }
 
-    if (*value && *value >= (limit / scale)) {
+    if (*value && *value > (limit / scale)) {
         virReportError(VIR_ERR_OVERFLOW, _("value too large: %llu%s"),
                        *value, suffix);
         return -1;