Projects
Eulaceura:Mainline:GA
xfsdump
_service:obs_scm:0001-xfsdump-fix-memory-leak.p...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:obs_scm:0001-xfsdump-fix-memory-leak.patch of Package xfsdump
From 577e51a5abdda97ffce73637d67f5f88d7e93ac7 Mon Sep 17 00:00:00 2001 From: Pavel Reichl <preichl@redhat.com> 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" <djwong@kernel.org> Signed-off-by: Pavel Reichl <preichl@redhat.com> Signed-off-by: Carlos Maiolino <cem@kernel.org> --- 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
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2