33 lines
902 B
Diff
33 lines
902 B
Diff
From 626ea66f3d54ba6e749230d3aa0ce8f4ddfded9c Mon Sep 17 00:00:00 2001
|
|
From: lvgenggeng <lvgenggeng@uniontech.com>
|
|
Date: Tue, 31 May 2022 08:37:38 +0800
|
|
Subject: [PATCH] ping: Fix potential memory leakage
|
|
|
|
If user use '-p' opt multi-times, the previous pointer generated by
|
|
strdup() will be discarded.
|
|
|
|
Closes: https://github.com/iputils/iputils/pull/409
|
|
|
|
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
|
|
Reviewed-by: Petr Vorel <pvorel@suse.cz>
|
|
Signed-off-by: lvgenggeng <lvgenggeng@uniontech.com>
|
|
---
|
|
ping/ping.c | 1 +
|
|
1 file changed, 1 insertion(+)
|
|
|
|
diff --git a/ping/ping.c b/ping/ping.c
|
|
index 8a7f701..10f2cf3 100644
|
|
--- a/ping/ping.c
|
|
+++ b/ping/ping.c
|
|
@@ -449,6 +449,7 @@ main(int argc, char **argv)
|
|
break;
|
|
case 'p':
|
|
rts.opt_pingfilled = 1;
|
|
+ free(outpack_fill);
|
|
outpack_fill = strdup(optarg);
|
|
if (!outpack_fill)
|
|
error(2, errno, _("memory allocation failed"));
|
|
--
|
|
2.27.0
|
|
|