ovs-appctl can crash with missing timeout argument.
  # ovs-appctl --timeout= dpif-netdev/pmd-stats-show

Fix by using strtol and validating the timeout value.

Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodire...@intel.com>
---
 utilities/ovs-appctl.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/utilities/ovs-appctl.c b/utilities/ovs-appctl.c
index 8f87cc4..2543ee9 100644
--- a/utilities/ovs-appctl.c
+++ b/utilities/ovs-appctl.c
@@ -127,6 +127,7 @@ parse_command_line(int argc, char *argv[])
     char *short_options_ = 
ovs_cmdl_long_options_to_short_options(long_options);
     char *short_options = xasprintf("+%s", short_options_);
     const char *target;
+    int timeout;
     int e_options;
 
     target = NULL;
@@ -165,7 +166,13 @@ parse_command_line(int argc, char *argv[])
             exit(EXIT_SUCCESS);
 
         case 'T':
-            time_alarm(atoi(optarg));
+            timeout = strtol(optarg, NULL, 10);
+            if (timeout <= 0) {
+                ovs_fatal(0, "timeout value %s on -t or --timeout is invalid",
+                               optarg);
+            } else {
+                time_alarm(timeout);
+            }
             break;
 
         case 'V':
-- 
2.4.11

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to