Subject: Re: [patch iproute2 1/2] tc: action: fix crash caused by incorrect *argv check

From: Stephen Hemminger <[email-masked]>
Date: Tue, 23 Jul 2019 10:47:32 -0700

On Tue, 23 Jul 2019 13:25:37 +0200
Jiri Pirko <[email-masked]> wrote:

> From: Jiri Pirko <[email-masked]>
> 
> One cannot depend on *argv being null in case of no arg is left on the
> command line. For example in batch mode, this is not always true. Check
> argc instead to prevent crash.
> 
> Reported-by: Alex Kushnarov <[email-masked]>
> Fixes: fd8b3d2c1b9b ("actions: Add support for user cookies")
> Signed-off-by: Jiri Pirko <[email-masked]>
> ---
>  tc/m_action.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tc/m_action.c b/tc/m_action.c
> index ab6bc0ad28ff..0f9c3a27795d 100644
> --- a/tc/m_action.c
> +++ b/tc/m_action.c
> @@ -222,7 +222,7 @@ done0:
>  				goto bad_val;
>  			}
>  
> -			if (*argv && strcmp(*argv, "cookie") == 0) {
> +			if (argc && strcmp(*argv, "cookie") == 0) {
>  				size_t slen;
>  
>  				NEXT_ARG();

Ok, but we should also fix batch mode to null last argv