summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-09-30 18:06:32 +0200
committerThomas Haller <thaller@redhat.com>2020-10-01 17:37:15 +0200
commit456d26d816ad2d506d4027138939b7612cc39390 (patch)
treea05792ab71e9762c7b12a9071a412b8ef948fe3f
parentdc559a9af7bf3f50ead67dfce2179c4652f1ce7f (diff)
downloadNetworkManager-456d26d816ad2d506d4027138939b7612cc39390.tar.gz
platform/tests: fix bug in nmtstp_ip_address_check_lifetime() calculating timeouts with unsigned integers
As one of the arguments in unsigned, the calculation is performed as unsigned integers. That can actually lead to the wrong result. Fix it by casting to the right (signed) types.
-rw-r--r--src/platform/tests/test-common.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/platform/tests/test-common.c b/src/platform/tests/test-common.c
index 89475f41f3..e305357a7a 100644
--- a/src/platform/tests/test-common.c
+++ b/src/platform/tests/test-common.c
@@ -955,8 +955,8 @@ nmtstp_ip_address_check_lifetime(const NMPlatformIPAddress *addr,
if (adr != NM_PLATFORM_LIFETIME_PERMANENT)
return FALSE;
} else {
- if (adr - offset <= lft - CHECK_LIFETIME_MAX_DIFF
- || adr - offset >= lft + CHECK_LIFETIME_MAX_DIFF)
+ if (((gint64) adr) - offset <= ((gint64) lft) - CHECK_LIFETIME_MAX_DIFF
+ || ((gint64) adr) - offset >= ((gint64) lft) + CHECK_LIFETIME_MAX_DIFF)
return FALSE;
}
}