[ovs-dev] [PATCH 03/11] ovs-appctl: Fix possible null pointer argument.

Ben Pfaff blp at ovn.org
Mon Oct 30 19:26:38 UTC 2017


On Sat, Oct 28, 2017 at 10:31:50AM -0700, William Tu wrote:
> Clang reports possible optarg as null pointer passed to atoi.
> Fix it by adding ovs_assert check before.
> 
> Signed-off-by: William Tu <u9012063 at gmail.com>
> ---
>  utilities/ovs-appctl.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/utilities/ovs-appctl.c b/utilities/ovs-appctl.c
> index 8f87cc4f6c6e..cc1326bc9478 100644
> --- a/utilities/ovs-appctl.c
> +++ b/utilities/ovs-appctl.c
> @@ -165,6 +165,7 @@ parse_command_line(int argc, char *argv[])
>              exit(EXIT_SUCCESS);
>  
>          case 'T':
> +            ovs_assert(optarg);
>              time_alarm(atoi(optarg));
>              break;

This is an example of "converting SIGSEGV to SIGABRT" as I mentioned
earlier.  I don't think it is valuable; both the computer and the human
reader can understand that atoi(optarg) implies that optarg is nonnull.


More information about the dev mailing list