summaryrefslogtreecommitdiff
path: root/lib/dpctl.c
diff options
context:
space:
mode:
authorZhiqi Chen <chenzhiqi.123@bytedance.com>2023-05-10 16:35:37 +0800
committerIlya Maximets <i.maximets@ovn.org>2023-05-11 21:40:14 +0200
commitb60fb752e395fddd8bbffe8c90cd285ece0bc846 (patch)
treed32d72e2cbc4feb239e10ef3fec4843af5b2260d /lib/dpctl.c
parent4ddfdaff1c20ef7199837455741e00261de7fd61 (diff)
downloadopenvswitch-b60fb752e395fddd8bbffe8c90cd285ece0bc846.tar.gz
dpctl: Fix dereferencing null pointer in parse_ct_limit_zones().branch-3.0
Command with empty string following "dpctl/ct-get-limits zone=" such as "ovs-appctl dpctl/ct-get-limits zone=" will cause parse_ct_limit_zones() dereferencing null. Signed-off-by: Zhiqi Chen <chenzhiqi.123@bytedance.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Diffstat (limited to 'lib/dpctl.c')
-rw-r--r--lib/dpctl.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/dpctl.c b/lib/dpctl.c
index 742fbce2d..0fc053e06 100644
--- a/lib/dpctl.c
+++ b/lib/dpctl.c
@@ -2174,7 +2174,7 @@ parse_ct_limit_zones(const char *argv, struct ovs_list *zone_limits,
argcopy = xstrdup(argv + 5);
next_zone = strtok_r(argcopy, ",", &save_ptr);
- do {
+ while (next_zone != NULL) {
if (ovs_scan(next_zone, "%"SCNu16, &zone)) {
ct_dpif_push_zone_limit(zone_limits, zone, 0, 0);
} else {
@@ -2182,7 +2182,8 @@ parse_ct_limit_zones(const char *argv, struct ovs_list *zone_limits,
free(argcopy);
return EINVAL;
}
- } while ((next_zone = strtok_r(NULL, ",", &save_ptr)) != NULL);
+ next_zone = strtok_r(NULL, ",", &save_ptr);
+ }
free(argcopy);
return 0;