pamp: increase memory allocation failure judgment
This commit is contained in:
parent
452356d36e
commit
24fae975f6
@ -0,0 +1,41 @@
|
||||
From b51ef773ad5cbd3eb9e348df4f70eb03307ce044 Mon Sep 17 00:00:00 2001
|
||||
From: EulerOSWander <314264452@qq.com>
|
||||
Date: Mon, 12 Jun 2023 14:19:30 +0800
|
||||
Subject: [PATCH] pmap: Increase memory allocation failure judgment
|
||||
|
||||
Call trace:
|
||||
#0 __vsnprintf_internal
|
||||
#1 0x00007f967aedd656 in __GI___snprintf
|
||||
#2 0x00005612da28c707 in snprintf
|
||||
#3 config_read (rc_filename=<optimized out>) at pmap.c:885
|
||||
#4 0x00005612da28b8c0 int main at pmap.c:1144
|
||||
|
||||
The above stack is caused by calling a null pointer
|
||||
after the memory allocation fails. Increase the null
|
||||
pointer judgment.
|
||||
|
||||
signed-off-by: zhoujie <zhoujie133@huawei.com>
|
||||
---
|
||||
src/pmap.c | 6 +++++-
|
||||
1 file changed, 5 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/pmap.c b/src/pmap.c
|
||||
index 658b2501..74d57dab 100644
|
||||
--- a/src/pmap.c
|
||||
+++ b/src/pmap.c
|
||||
@@ -881,7 +881,11 @@ static int config_read (char *rc_filename)
|
||||
}
|
||||
|
||||
/* add the field in the list */
|
||||
- cnf_listnode = calloc(1, sizeof *cnf_listnode);
|
||||
+ if (!(cnf_listnode = calloc(1, sizeof *cnf_listnode))) {
|
||||
+ xwarnx(_("memory allocation failed"));
|
||||
+ fclose(f);
|
||||
+ return 0;
|
||||
+ }
|
||||
snprintf(cnf_listnode -> description, sizeof(cnf_listnode -> description), "%s", token);
|
||||
cnf_listnode -> next = cnf_listhead;
|
||||
cnf_listhead = cnf_listnode;
|
||||
--
|
||||
2.33.0
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
Name: procps-ng
|
||||
Version: 4.0.2
|
||||
Release: 4
|
||||
Release: 5
|
||||
Summary: Utilities that provide system information.
|
||||
License: GPL+ and GPLv2 and GPLv2+ and GPLv3+ and LGPLv2+
|
||||
URL: https://sourceforge.net/projects/procps-ng/
|
||||
@ -16,6 +16,7 @@ Patch4: backport-top-address-the-missing-guest-tics-for-summary-area.patch
|
||||
Patch5: backport-0001-ps-address-missing-or-corrupted-fields-with-m-option.patch
|
||||
Patch6: backport-0002-ps-trade-previous-fix-for-final-solution-to-m-option.patch
|
||||
Patch7: backport-top-lessen-summary-cpu-distortions-with-first-displa.patch
|
||||
Patch8: backport-pmap-Increase-memory-allocation-failure-judgment.patch
|
||||
|
||||
BuildRequires: ncurses-devel libtool autoconf automake gcc gettext-devel systemd-devel
|
||||
|
||||
@ -98,6 +99,9 @@ ln -s %{_bindir}/pidof %{buildroot}%{_sbindir}/pidof
|
||||
%{_mandir}/man*
|
||||
|
||||
%changelog
|
||||
* Mon Jun 26 2023 zhoujie <zhoujie133@huawei.com> - 4.0.2-5
|
||||
- pamp: increase memory allocation failure judgment
|
||||
|
||||
* Tue Jun 13 2023 zhoujie <zhoujie133@huawei.com> - 4.0.2-4
|
||||
- top: first time display delay
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user