diff options
author | Ilya Maximets <i.maximets@samsung.com> | 2018-08-14 10:53:15 +0300 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2018-08-15 11:36:18 -0700 |
commit | cbcf40a847c0539fec36e82410f0966f13517964 (patch) | |
tree | 0970a16b5b1ba1e7c34826c6e74197f4dd59cfcb /vtep | |
parent | b302f315b38b9bf35036ef8d0542bf83bb0e0752 (diff) | |
download | openvswitch-cbcf40a847c0539fec36e82410f0966f13517964.tar.gz |
utilities: Fix and unify parsing of timeout option.
Parsing of the '--timeout' option implemented differently
for every single control utility and, which is more
important, highly inaccurate. In most cases unsigned result
of 'strtoul' stored in signed variable. Parsing failures are
not tracked. 'ovs-appctl' even uses just 'atoi' without any
checking of the argument or result.
This patch unifies the parsing by using 'str_to_uint'.
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'vtep')
-rw-r--r-- | vtep/vtep-ctl.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/vtep/vtep-ctl.c b/vtep/vtep-ctl.c index 35ab43588..fb3c81e2b 100644 --- a/vtep/vtep-ctl.c +++ b/vtep/vtep-ctl.c @@ -65,7 +65,7 @@ static bool oneline; static bool dry_run; /* --timeout: Time to wait for a connection to 'db'. */ -static int timeout; +static unsigned int timeout; /* Format for table output. */ static struct table_style table_style = TABLE_STYLE_DEFAULT; @@ -252,10 +252,8 @@ parse_options(int argc, char *argv[], struct shash *local_options) exit(EXIT_SUCCESS); case 't': - timeout = strtoul(optarg, NULL, 10); - if (timeout < 0) { - ctl_fatal("value %s on -t or --timeout is invalid", - optarg); + if (!str_to_uint(optarg, 10, &timeout) || !timeout) { + ctl_fatal("value %s on -t or --timeout is invalid", optarg); } break; |