summaryrefslogtreecommitdiff
path: root/backport-Fix-header-leak-in-rpmInstall.patch
blob: 67dc5817a276fcbf7543cb9dd86f65ba072904e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
From 15a0c73f4698bc58fa2a633d46527c7813150f3a Mon Sep 17 00:00:00 2001
From: xujing <xujing125@huawei.com>
Date: Thu, 24 Nov 2022 10:43:11 +0800
Subject: [PATCH] Fix header leak in rpmInstall()

When rpm installs a package, the header from tryReadHeader()
in rpmInstall() is leaked in some cases.
---
 lib/rpminstall.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/rpminstall.c b/lib/rpminstall.c
index 9167dbdde..097599681 100644
--- a/lib/rpminstall.c
+++ b/lib/rpminstall.c
@@ -561,13 +561,14 @@ restart:
 	    rc = tryReadManifest(eiu);
 	    if (rc == RPMRC_OK) {
 	        eiu->prevx++;
+		headerFree(h);
 	        goto restart;
 	    }
 	}
 
 	if (headerIsSource(h)) {
+	    headerFree(h);
 	    if (ia->installInterfaceFlags & INSTALL_FRESHEN) {
-		headerFree(h);
 	        continue;
 	    }
 	    rpmlog(RPMLOG_DEBUG, "\tadded source package [%d]\n",
@@ -592,6 +593,7 @@ restart:
 		rpmlog(RPMLOG_ERR, _("package %s is not relocatable\n"),
 		       headerGetString(h, RPMTAG_NAME));
 		eiu->numFailed++;
+		headerFree(h);
 		goto exit;
 	    }
 	}
-- 
2.33.0