diff --git a/0001-xfsdump-fix-memory-leak.patch b/0001-xfsdump-fix-memory-leak.patch new file mode 100644 index 0000000..2621149 --- /dev/null +++ b/0001-xfsdump-fix-memory-leak.patch @@ -0,0 +1,48 @@ +From 577e51a5abdda97ffce73637d67f5f88d7e93ac7 Mon Sep 17 00:00:00 2001 +From: Pavel Reichl +Date: Thu, 14 Dec 2023 21:25:49 +0100 +Subject: xfsdump: Fix memory leak + +Fix memory leak found by coverity. + +>>> CID 1554295: Resource leaks (RESOURCE_LEAK) +>>> Failing to save or free storage allocated by strdup(path) leaks it. + +Reviewed-by: "Darrick J. Wong" +Signed-off-by: Pavel Reichl +Signed-off-by: Carlos Maiolino +--- + restore/tree.c | 15 ++++++++++++++- + 1 file changed, 14 insertions(+), 1 deletion(-) + +diff --git a/restore/tree.c b/restore/tree.c +index 6f3180f5..4707fdc9 100644 +--- a/restore/tree.c ++++ b/restore/tree.c +@@ -4977,9 +4977,22 @@ static int + mkdir_r(char *path) + { + struct stat sbuf; ++ char *path_copy; ++ int ret; + + if (stat(path, &sbuf) < 0) { +- if (mkdir_r(dirname(strdup(path))) < 0) ++ path_copy = strdup(path); ++ if (!path_copy) { ++ mlog(MLOG_TRACE | MLOG_ERROR | MLOG_TREE, ++ _("unable to allocate memory for a path\n")); ++ mlog_exit(EXIT_ERROR, RV_ERROR); ++ exit(1); ++ } ++ ++ ret = mkdir_r(dirname(path_copy)); ++ free(path_copy); ++ ++ if (ret < 0) + return -1; + return mkdir(path, 0755); + } +-- +cgit 1.2.3-korg + diff --git a/xfsdump.spec b/xfsdump.spec index 2397b4e..222d54b 100644 --- a/xfsdump.spec +++ b/xfsdump.spec @@ -1,6 +1,6 @@ Name: xfsdump Version: 3.1.12 -Release: 1 +Release: 2 Summary: Tools create and restore for the XFS filesystem License: GPLv2 URL: http://xfs.org @@ -10,6 +10,8 @@ BuildRequires: libtool, gettext, gawk BuildRequires: xfsprogs-devel, ncurses-devel, libuuid-devel, libattr-devel Requires: xfsprogs, attr +Patch0: 0001-xfsdump-fix-memory-leak.patch + %description xfsdump tools create and restore backups of directory trees on XFS filesystems. @@ -48,6 +50,9 @@ mkdir -p %{buildroot}/%{_sharedstatedir}/xfsdump/inventory %changelog +* Wed Mar 20 2024 liuh - 3.1.12-2 +- xfsdump: fix memory leak + * Wed Feb 8 2023 wuguanghao - 3.1.12-1 - upgrade xfsdump version to 3.1.12-1