提交 19e7c04d 编写于 作者: B Bing Bu Cao 提交者: Eric Blake

util: fix two virCompareLimitUlong bugs

The helper function virCompareLimitUlong compares limit values,
where value of 0 is equal to unlimited. If the latter parameter is 0,
it should return -1 instead of 1, hence the user can only set hard_limit when
swap_hard_limit currently is unlimited.

Worse, all callers pass 2 64-bit values, but on 32-bit platforms,
the second argument was silently truncated to 32 bits, which
could lead to incorrect computations.
Signed-off-by: NBing Bu Cao <mars@linux.vnet.ibm.com>
Signed-off-by: NEric Blake <eblake@redhat.com>
上级 1fb4d892
......@@ -2062,11 +2062,14 @@ virFindFCHostCapableVport(const char *sysfs_prefix ATTRIBUTE_UNUSED)
* Returns 0 if the numbers are equal, -1 if b is greater, 1 if a is greater.
*/
int
virCompareLimitUlong(unsigned long long a, unsigned long b)
virCompareLimitUlong(unsigned long long a, unsigned long long b)
{
if (a == b)
return 0;
if (!b)
return -1;
if (a == 0 || a > b)
return 1;
......
......@@ -168,7 +168,7 @@ char *virGetFCHostNameByWWN(const char *sysfs_prefix,
char *virFindFCHostCapableVport(const char *sysfs_prefix);
int virCompareLimitUlong(unsigned long long a, unsigned long b);
int virCompareLimitUlong(unsigned long long a, unsigned long long b);
int virParseOwnershipIds(const char *label, uid_t *uidPtr, gid_t *gidPtr);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册