[ovs-dev] [PATCH 11/11] ovs-testcontroller: Fix possible null pointer to atoi.

William Tu u9012063 at gmail.com
Sat Oct 28 17:31:58 UTC 2017


Clang reports possible optarg as null passed to atoi.
Fix it by adding ovs_assert check.

Signed-off-by: William Tu <u9012063 at gmail.com>
---
 utilities/ovs-testcontroller.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/utilities/ovs-testcontroller.c b/utilities/ovs-testcontroller.c
index b4a451286455..be28d5494ec0 100644
--- a/utilities/ovs-testcontroller.c
+++ b/utilities/ovs-testcontroller.c
@@ -318,6 +318,7 @@ parse_options(int argc, char *argv[])
             if (!strcmp(optarg, "permanent")) {
                 max_idle = OFP_FLOW_PERMANENT;
             } else {
+                ovs_assert(optarg);
                 max_idle = atoi(optarg);
                 if (max_idle < 1 || max_idle > 65535) {
                     ovs_fatal(0, "--max-idle argument must be between 1 and "
@@ -327,6 +328,7 @@ parse_options(int argc, char *argv[])
             break;
 
         case 'q':
+            ovs_assert(optarg);
             default_queue = atoi(optarg);
             break;
 
-- 
2.7.4



More information about the dev mailing list