diff mbox series

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

Message ID 1509211918-14829-12-git-send-email-u9012063@gmail.com
State Changes Requested
Headers show
Series Fix clang static analysis null pointer bugs. | expand

Commit Message

William Tu Oct. 28, 2017, 5:31 p.m. UTC
Clang reports possible optarg as null passed to atoi.
Fix it by adding ovs_assert check.

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

Comments

Mark Michelson Oct. 30, 2017, 3:25 p.m. UTC | #1
Looks good to me

On Sat, Oct 28, 2017 at 12:38 PM William Tu <u9012063@gmail.com> wrote:

> Clang reports possible optarg as null passed to atoi.
> Fix it by adding ovs_assert check.
>
> Signed-off-by: William Tu <u9012063@gmail.com>
>
Acked-by: Mark Michelson <mmichels@redhat.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
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>
diff mbox series

Patch

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;