diff mbox series

[ovs-dev,05/11] ovs-ofctl: Fix possible null pointer.

Message ID 1509211918-14829-6-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 null pointer of optarg as argument to strtoul.
Fix it by adding ovs_assert check.

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

Comments

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

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

> Clang reports possible null pointer of optarg as argument to strtoul.
> Fix it by adding ovs_assert check.
>
> Signed-off-by: William Tu <u9012063@gmail.com>
>
Acked-by: Mark Michelson <mmichels@redhat.com>

> ---
>  utilities/ovs-ofctl.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c
> index 5b7f1b02104f..05c5995fa775 100644
> --- a/utilities/ovs-ofctl.c
> +++ b/utilities/ovs-ofctl.c
> @@ -262,6 +262,7 @@ parse_options(int argc, char *argv[])
>
>          switch (c) {
>          case 't':
> +            ovs_assert(optarg);
>              timeout = strtoul(optarg, NULL, 10);
>              if (timeout <= 0) {
>                  ovs_fatal(0, "value %s on -t or --timeout is not at least
> 1",
> --
> 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-ofctl.c b/utilities/ovs-ofctl.c
index 5b7f1b02104f..05c5995fa775 100644
--- a/utilities/ovs-ofctl.c
+++ b/utilities/ovs-ofctl.c
@@ -262,6 +262,7 @@  parse_options(int argc, char *argv[])
 
         switch (c) {
         case 't':
+            ovs_assert(optarg);
             timeout = strtoul(optarg, NULL, 10);
             if (timeout <= 0) {
                 ovs_fatal(0, "value %s on -t or --timeout is not at least 1",