netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iproute2] lnstat: fix strdup leak in -w argument parsing
@ 2022-02-15 20:53 Maxim Petrov
  2022-02-15 22:49 ` Stephen Hemminger
  0 siblings, 1 reply; 4+ messages in thread
From: Maxim Petrov @ 2022-02-15 20:53 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger

'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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-02-16 19:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-15 20:53 [PATCH iproute2] lnstat: fix strdup leak in -w argument parsing Maxim Petrov
2022-02-15 22:49 ` Stephen Hemminger
2022-02-16 19:40   ` Maxim Petrov
2022-02-16 19:42     ` Stephen Hemminger

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).