When no parameters other than the datapath are specified a segfault occurs.
Fix it by checking the argument access is inside the bounds. Signed-off-by: Paolo Valerio <pvale...@redhat.com> --- lib/dpctl.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/lib/dpctl.c b/lib/dpctl.c index 34ee7d0e2..3c555a559 100644 --- a/lib/dpctl.c +++ b/lib/dpctl.c @@ -2168,13 +2168,20 @@ static int dpctl_ct_set_limits(int argc, const char *argv[], struct dpctl_params *dpctl_p) { - struct dpif *dpif; - struct ds ds = DS_EMPTY_INITIALIZER; + struct ovs_list zone_limits = OVS_LIST_INITIALIZER(&zone_limits); int i = dp_arg_exists(argc, argv) ? 2 : 1; + struct ds ds = DS_EMPTY_INITIALIZER; + struct dpif *dpif = NULL; uint32_t default_limit; - struct ovs_list zone_limits = OVS_LIST_INITIALIZER(&zone_limits); + int error; + + if (i >= argc) { + ds_put_cstr(&ds, "too few arguments"); + error = EINVAL; + goto error; + } - int error = opt_dpif_open(argc, argv, dpctl_p, INT_MAX, &dpif); + error = opt_dpif_open(argc, argv, dpctl_p, INT_MAX, &dpif); if (error) { return error; } @@ -2261,11 +2268,17 @@ static int dpctl_ct_del_limits(int argc, const char *argv[], struct dpctl_params *dpctl_p) { - struct dpif *dpif; + struct ovs_list zone_limits = OVS_LIST_INITIALIZER(&zone_limits); + int i = dp_arg_exists(argc, argv) ? 2 : 1; struct ds ds = DS_EMPTY_INITIALIZER; + struct dpif *dpif = NULL; int error; - int i = dp_arg_exists(argc, argv) ? 2 : 1; - struct ovs_list zone_limits = OVS_LIST_INITIALIZER(&zone_limits); + + if (i >= argc) { + ds_put_cstr(&ds, "too few arguments"); + error = EINVAL; + goto error; + } error = opt_dpif_open(argc, argv, dpctl_p, 4, &dpif); if (error) { -- 2.44.0 _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev