[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20220216130316.40073fc3@hermes.local>
Date: Wed, 16 Feb 2022 13:03:16 -0800
From: Stephen Hemminger <stephen@...workplumber.org>
To: Maxim Petrov <mmrmaximuzz@...il.com>
Cc: netdev@...r.kernel.org
Subject: Re: [PATCH v2 iproute2] lnstat: fix strdup leak in -w argument
parsing
On Wed, 16 Feb 2022 23:35:43 +0300
Maxim Petrov <mmrmaximuzz@...il.com> wrote:
> 'tmp' string is copied for safe tokenizing, but it is not required after
> getting all the widths in -w option. Use strdupa instead of strdup to avoid
> explicit memory leak and to not trigger valgrind here.
>
> Signed-off-by: Maxim Petrov <mmrmaximuzz@...il.com>
> ---
> Changes in V2:
> * Use strdupa instead of strdup/free
>
> misc/lnstat.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/misc/lnstat.c b/misc/lnstat.c
> index 98904d45..d7e1d8c9 100644
> --- a/misc/lnstat.c
> +++ b/misc/lnstat.c
> @@ -314,7 +314,7 @@ int main(int argc, char **argv)
> sscanf(optarg, "%u", &hdr);
> break;
> case 'w':
> - tmp = strdup(optarg);
> + tmp = strdupa(optarg);
> if (!tmp)
> break;
> i = 0;
I went with your earlier patch, just was asking.
Powered by blists - more mailing lists