|
|
c401cc |
From da332b31effd204778ffc245184810f3b4137246 Mon Sep 17 00:00:00 2001
|
|
|
c401cc |
Message-Id: <da332b31effd204778ffc245184810f3b4137246.1386932211.git.jdenemar@redhat.com>
|
|
|
c401cc |
From: Bing Bu Cao <mars@linux.vnet.ibm.com>
|
|
|
c401cc |
Date: Tue, 10 Dec 2013 10:03:54 +0100
|
|
|
c401cc |
Subject: [PATCH] util: fix two virCompareLimitUlong bugs
|
|
|
c401cc |
|
|
|
c401cc |
https://bugzilla.redhat.com/show_bug.cgi?id=1024272
|
|
|
c401cc |
|
|
|
c401cc |
The helper function virCompareLimitUlong compares limit values,
|
|
|
c401cc |
where value of 0 is equal to unlimited. If the latter parameter is 0,
|
|
|
c401cc |
it should return -1 instead of 1, hence the user can only set hard_limit when
|
|
|
c401cc |
swap_hard_limit currently is unlimited.
|
|
|
c401cc |
|
|
|
c401cc |
Worse, all callers pass 2 64-bit values, but on 32-bit platforms,
|
|
|
c401cc |
the second argument was silently truncated to 32 bits, which
|
|
|
c401cc |
could lead to incorrect computations.
|
|
|
c401cc |
|
|
|
c401cc |
Signed-off-by: Bing Bu Cao <mars@linux.vnet.ibm.com>
|
|
|
c401cc |
Signed-off-by: Eric Blake <eblake@redhat.com>
|
|
|
c401cc |
(cherry picked from commit 19e7c04dce34afeb9a762471e09777de7d219db8)
|
|
|
c401cc |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
c401cc |
---
|
|
|
c401cc |
src/util/virutil.c | 5 ++++-
|
|
|
c401cc |
src/util/virutil.h | 2 +-
|
|
|
c401cc |
2 files changed, 5 insertions(+), 2 deletions(-)
|
|
|
c401cc |
|
|
|
c401cc |
diff --git a/src/util/virutil.c b/src/util/virutil.c
|
|
|
c401cc |
index 21827f2..208d0b6 100644
|
|
|
c401cc |
--- a/src/util/virutil.c
|
|
|
c401cc |
+++ b/src/util/virutil.c
|
|
|
c401cc |
@@ -2030,11 +2030,14 @@ virFindFCHostCapableVport(const char *sysfs_prefix ATTRIBUTE_UNUSED)
|
|
|
c401cc |
* Returns 0 if the numbers are equal, -1 if b is greater, 1 if a is greater.
|
|
|
c401cc |
*/
|
|
|
c401cc |
int
|
|
|
c401cc |
-virCompareLimitUlong(unsigned long long a, unsigned long b)
|
|
|
c401cc |
+virCompareLimitUlong(unsigned long long a, unsigned long long b)
|
|
|
c401cc |
{
|
|
|
c401cc |
if (a == b)
|
|
|
c401cc |
return 0;
|
|
|
c401cc |
|
|
|
c401cc |
+ if (!b)
|
|
|
c401cc |
+ return -1;
|
|
|
c401cc |
+
|
|
|
c401cc |
if (a == 0 || a > b)
|
|
|
c401cc |
return 1;
|
|
|
c401cc |
|
|
|
c401cc |
diff --git a/src/util/virutil.h b/src/util/virutil.h
|
|
|
c401cc |
index 2c8b0ec..2229c73 100644
|
|
|
c401cc |
--- a/src/util/virutil.h
|
|
|
c401cc |
+++ b/src/util/virutil.h
|
|
|
c401cc |
@@ -172,7 +172,7 @@ char *virGetFCHostNameByWWN(const char *sysfs_prefix,
|
|
|
c401cc |
|
|
|
c401cc |
char *virFindFCHostCapableVport(const char *sysfs_prefix);
|
|
|
c401cc |
|
|
|
c401cc |
-int virCompareLimitUlong(unsigned long long a, unsigned long b);
|
|
|
c401cc |
+int virCompareLimitUlong(unsigned long long a, unsigned long long b);
|
|
|
c401cc |
|
|
|
c401cc |
int virParseOwnershipIds(const char *label, uid_t *uidPtr, gid_t *gidPtr);
|
|
|
c401cc |
|
|
|
c401cc |
--
|
|
|
c401cc |
1.8.5.1
|
|
|
c401cc |
|