diff options
| author | CoprDistGit <infra@openeuler.org> | 2023-09-10 03:05:12 +0000 |
|---|---|---|
| committer | CoprDistGit <infra@openeuler.org> | 2023-09-10 03:05:12 +0000 |
| commit | 2bc2b430bc4c1a9a0bfd1c01da68bd53bf7da052 (patch) | |
| tree | a2af4fd609c7decacbf0ea11926ea338596fb179 /backport-Fix-fileleak-and-memleak-in-rpmInstall.patch | |
| parent | 0ae9f87336a3d78d8fbc0a1e5c75cba5f9cf8597 (diff) | |
automatic import of rpm
Diffstat (limited to 'backport-Fix-fileleak-and-memleak-in-rpmInstall.patch')
| -rw-r--r-- | backport-Fix-fileleak-and-memleak-in-rpmInstall.patch | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/backport-Fix-fileleak-and-memleak-in-rpmInstall.patch b/backport-Fix-fileleak-and-memleak-in-rpmInstall.patch new file mode 100644 index 0000000..fdf3c56 --- /dev/null +++ b/backport-Fix-fileleak-and-memleak-in-rpmInstall.patch @@ -0,0 +1,63 @@ +From f0f983b145583eeed618cf3cbc5d39bedd8af5a5 Mon Sep 17 00:00:00 2001 +From: xujing <xujing125@huawei.com> +Date: Mon, 28 Nov 2022 11:19:20 +0800 +Subject: [PATCH 2/3] Fix fileleak and memleak in rpmInstall + +The "*eiu->fnp" from "eiu->pkgURL[eiu->pkgx]" which is alloced. when +Fopen or rpmReadPackageFile fails in tryReadHeader, "*eiu->fnp" is +set to NULL but not freed. In addition, if "eiu->pkgState[eiu->pkgx]" +is set, the file is leaked too. Fix it. + +Only resource free is added, no other logic change. +--- + lib/rpminstall.c | 12 +++++++++--- + 1 file changed, 9 insertions(+), 3 deletions(-) + +diff --git a/lib/rpminstall.c b/lib/rpminstall.c +index b392cf1c3..90474fabf 100644 +--- a/lib/rpminstall.c ++++ b/lib/rpminstall.c +@@ -355,7 +355,6 @@ static int tryReadHeader(rpmts ts, struct rpmEIU * eiu, Header * hdrp) + fd = NULL; + } + eiu->numFailed++; +- *eiu->fnp = NULL; + return RPMRC_FAIL; + } + +@@ -371,7 +370,6 @@ static int tryReadHeader(rpmts ts, struct rpmEIU * eiu, Header * hdrp) + if (eiu->rpmrc == RPMRC_FAIL) { + rpmlog(RPMLOG_ERR, _("%s cannot be installed\n"), *eiu->fnp); + eiu->numFailed++; +- *eiu->fnp = NULL; + } + + return RPMRC_OK; +@@ -554,8 +552,12 @@ restart: + rpmlog(RPMLOG_DEBUG, "============== %s\n", *eiu->fnp); + (void) urlPath(*eiu->fnp, &fileName); + +- if (tryReadHeader(ts, eiu, &h) == RPMRC_FAIL) ++ if (tryReadHeader(ts, eiu, &h) == RPMRC_FAIL) { ++ if (eiu->pkgState[eiu->fnp - eiu->pkgURL] == 1) ++ (void) unlink(*eiu->fnp); ++ *eiu->fnp = _free(*eiu->fnp); + continue; ++ } + + if (eiu->rpmrc == RPMRC_NOTFOUND) { + rc = tryReadManifest(eiu); +@@ -564,6 +566,10 @@ restart: + headerFree(h); + goto restart; + } ++ } else if (eiu->rpmrc == RPMRC_FAIL) { ++ if (eiu->pkgState[eiu->fnp - eiu->pkgURL] == 1) ++ (void) unlink(*eiu->fnp); ++ *eiu->fnp = _free(*eiu->fnp); + } + + if (headerIsSource(h)) { +-- +2.27.0 + |
