add return value check for dynamic memory function
Add check for realloc function to ignore this coredump and exit with error output Signed-off-by: swf504 <suweifeng1@huawei.com>
This commit is contained in:
parent
dec02fb9ee
commit
91051566b9
@ -0,0 +1,37 @@
|
||||
From f927695b86c3de29e930d0b920154a6ba294421f Mon Sep 17 00:00:00 2001
|
||||
From: Weifeng Su <suweifeng1@huawei.com>
|
||||
Date: Sun, 25 Jun 2023 02:55:45 +0000
|
||||
Subject: libxcmd:add return value check for dynamic memory function
|
||||
|
||||
The result check was missed and It cause the coredump like:
|
||||
0x00005589f3e358dd in add_command (ci=0x5589f3e3f020 <health_cmd>) at command.c:37
|
||||
0x00005589f3e337d8 in init_commands () at init.c:37
|
||||
init (argc=<optimized out>, argv=0x7ffecfb0cd28) at init.c:102
|
||||
0x00005589f3e33399 in main (argc=<optimized out>, argv=<optimized out>) at init.c:112
|
||||
|
||||
Add check for realloc function to ignore this coredump and exit with
|
||||
error output
|
||||
|
||||
Signed-off-by: Weifeng Su <suweifeng1@huawei.com>
|
||||
---
|
||||
libxcmd/command.c | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
diff --git a/libxcmd/command.c b/libxcmd/command.c
|
||||
index a76d151..e260309 100644
|
||||
--- a/libxcmd/command.c
|
||||
+++ b/libxcmd/command.c
|
||||
@@ -34,6 +34,10 @@ add_command(
|
||||
const cmdinfo_t *ci)
|
||||
{
|
||||
cmdtab = realloc((void *)cmdtab, ++ncmds * sizeof(*cmdtab));
|
||||
+ if (!cmdtab) {
|
||||
+ perror(_("adding libxcmd command"));
|
||||
+ exit(1);
|
||||
+ }
|
||||
cmdtab[ncmds - 1] = *ci;
|
||||
qsort(cmdtab, ncmds, sizeof(*cmdtab), compare);
|
||||
}
|
||||
--
|
||||
2.33.0
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
Name: xfsprogs
|
||||
Version: 5.14.1
|
||||
Release: 9
|
||||
Release: 10
|
||||
Summary: Administration and debugging tools for the XFS file system
|
||||
License: GPL+ and LGPLv2+
|
||||
URL: https://xfs.wiki.kernel.org
|
||||
@ -25,6 +25,7 @@ Patch3: 0003-mkfs-prevent-corruption-of-passed-in-suboption-strin.patch
|
||||
Patch4: 0004-xfsprogs-Add-sw64-architecture.patch
|
||||
Patch5: 0005-xfs_db-use-preferable-macro-to-seek-offset-for-local.patch
|
||||
Patch6: 0006-mkfs.xfs-disable-inobtcount-feature.patch
|
||||
Patch7: 0007-libxcmd-add-return-value-check-for-dynamic-memory-fu.patch
|
||||
|
||||
%description
|
||||
xfsprogs are the userspace utilities that manage XFS filesystems.
|
||||
@ -108,6 +109,9 @@ rm -rf %{buildroot}%{_datadir}/doc/xfsprogs/
|
||||
|
||||
|
||||
%changelog
|
||||
* Sun Jun 25 2023 Weifeng Su <suweifeng1@huawei.com> - 5.14.1-10
|
||||
- add return value check for dynamic memory function
|
||||
|
||||
* Mon Jun 19 2023 wuguanghao <wuguanghao3@huawei.com> - 5.14.1-9
|
||||
- mkfs.xfs:disable inobtcount feature
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user