backport to fix potential memory leakage on -p option

Signed-off-by: lvgenggeng <lvgenggeng@uniontech.com>
This commit is contained in:
lvgenggeng 2022-06-20 10:03:49 +08:00
parent 0893ca249f
commit f437b3485a
2 changed files with 40 additions and 1 deletions

View File

@ -0,0 +1,32 @@
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

View File

@ -1,6 +1,6 @@
Name: iputils Name: iputils
Version: 20210722 Version: 20210722
Release: 5 Release: 6
Summary: Network monitoring tools including ping Summary: Network monitoring tools including ping
License: BSD and GPLv2+ License: BSD and GPLv2+
URL: https://github.com/iputils/iputils URL: https://github.com/iputils/iputils
@ -22,6 +22,7 @@ Patch0006: backport-ping6-Avoid-binding-to-non-VRF.patch
Patch0007: arping-Fix-exit-code-on-w-option.patch Patch0007: arping-Fix-exit-code-on-w-option.patch
Patch0008: backport-ping-Print-reply-from-Subnet-Router-anycast-address.patch Patch0008: backport-ping-Print-reply-from-Subnet-Router-anycast-address.patch
Patch0009: backport-ping-Print-reply-with-wrong-source-with-warning.patch Patch0009: backport-ping-Print-reply-with-wrong-source-with-warning.patch
Patch0010: backport-ping-Fix-potential-memory-leakage.patch
BuildRequires: gcc meson libidn2-devel openssl-devel libcap-devel libxslt BuildRequires: gcc meson libidn2-devel openssl-devel libcap-devel libxslt
BuildRequires: docbook5-style-xsl systemd iproute glibc-kernheaders gettext BuildRequires: docbook5-style-xsl systemd iproute glibc-kernheaders gettext
@ -120,6 +121,12 @@ install -cp ifenslave.8 ${RPM_BUILD_ROOT}%{_mandir}/man8/
%{_unitdir}/ninfod.service %{_unitdir}/ninfod.service
%changelog %changelog
* Mon Jun 20 2022 lvgenggeng <lvgenggeng@uniontech.com> - 20210722-6
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:backport to fix potential memory leakage on -p option
* Sat May 07 2022 eaglegai <eaglegai@163.com> - 20210722-5 * Sat May 07 2022 eaglegai <eaglegai@163.com> - 20210722-5
- Type:bugfix - Type:bugfix
- ID:NA - ID:NA