netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Maxim Petrov <mmrmaximuzz@gmail.com>
To: netdev@vger.kernel.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH iproute2] lnstat: fix strdup leak in -w argument parsing
Date: Tue, 15 Feb 2022 23:53:47 +0300	[thread overview]
Message-ID: <9766312d-58ae-4219-036e-73a587de1111@gmail.com> (raw)

'tmp' string is used for safe tokenizing, but it is not required after
getting all the widths in -w option. As 'tmp' string is obtained by strdup
call, the caller has to deallocate it to avoid memory leak.

Signed-off-by: Maxim Petrov <mmrmaximuzz@gmail.com>
---
 misc/lnstat.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/misc/lnstat.c b/misc/lnstat.c
index 98904d45..c3293a8e 100644
--- a/misc/lnstat.c
+++ b/misc/lnstat.c
@@ -331,6 +331,7 @@ int main(int argc, char **argv)
 				for (i = 0; i < MAX_FIELDS; i++)
 					fp.params[i].print.width = len;
 			}
+			free(tmp);
 			break;
 		default:
 			usage(argv[0], 1);
-- 
2.25.1

             reply	other threads:[~2022-02-15 20:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-15 20:53 Maxim Petrov [this message]
2022-02-15 22:49 ` [PATCH iproute2] lnstat: fix strdup leak in -w argument parsing Stephen Hemminger
2022-02-16 19:40   ` Maxim Petrov
2022-02-16 19:42     ` Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9766312d-58ae-4219-036e-73a587de1111@gmail.com \
    --to=mmrmaximuzz@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).