nss: handle leases with infinite expiry time

After v6.3.0-rc1~64 a lease can have infinite expiry time. This
means that the expiration time will appear as a value of zero.
Do the expiration check only if the expiration time is not zero.

Fixes: 97a0aa2467
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Michal Privoznik 2020-12-18 16:09:16 +01:00
parent 5dd53684e1
commit 7f93905e45
3 changed files with 11 additions and 2 deletions

View File

@ -21,5 +21,12 @@
"ip-address": "192.168.122.2", "ip-address": "192.168.122.2",
"mac-address": "52:54:00:11:22:33", "mac-address": "52:54:00:11:22:33",
"expiry-time": 2000000000 "expiry-time": 2000000000
},
{
"ip-address": "192.168.122.3",
"mac-address": "52:54:00:a4:6f:91",
"hostname": "fedora",
"client-id": "01:52:54:00:a4:6f:91",
"expiry-time": 0
} }
] ]

View File

@ -173,7 +173,7 @@ mymain(void)
} while (0) } while (0)
# if !defined(LIBVIRT_NSS_GUEST) # if !defined(LIBVIRT_NSS_GUEST)
DO_TEST("fedora", AF_INET, "192.168.122.197", "192.168.122.198", "192.168.122.199"); DO_TEST("fedora", AF_INET, "192.168.122.197", "192.168.122.198", "192.168.122.199", "192.168.122.3");
DO_TEST("gentoo", AF_INET, "192.168.122.254"); DO_TEST("gentoo", AF_INET, "192.168.122.254");
DO_TEST("gentoo", AF_INET6, "2001:1234:dead:beef::2"); DO_TEST("gentoo", AF_INET6, "2001:1234:dead:beef::2");
DO_TEST("gentoo", AF_UNSPEC, "192.168.122.254"); DO_TEST("gentoo", AF_UNSPEC, "192.168.122.254");

View File

@ -276,7 +276,8 @@ findLeasesParserEndMap(void *ctx)
found = true; found = true;
} }
DEBUG("Found %d", found); DEBUG("Found %d", found);
if (parser->entry.expiry < parser->now) { if (parser->entry.expiry != 0 &&
parser->entry.expiry < parser->now) {
DEBUG("Entry expired at %llu vs now %llu", DEBUG("Entry expired at %llu vs now %llu",
parser->entry.expiry, parser->now); parser->entry.expiry, parser->now);
found = false; found = false;
@ -298,6 +299,7 @@ findLeasesParserEndMap(void *ctx)
free(parser->entry.macaddr); free(parser->entry.macaddr);
free(parser->entry.ipaddr); free(parser->entry.ipaddr);
free(parser->entry.hostname); free(parser->entry.hostname);
parser->entry.expiry = 0;
parser->entry.macaddr = NULL; parser->entry.macaddr = NULL;
parser->entry.ipaddr = NULL; parser->entry.ipaddr = NULL;
parser->entry.hostname = NULL; parser->entry.hostname = NULL;