]> git.proxmox.com Git - lxcfs.git/blame - debian/patches/0003-fix-leak-in-realloc-loop-in-must_strcat_pid.patch
Add quilt, libpam0g-dev to Build-Depends
[lxcfs.git] / debian / patches / 0003-fix-leak-in-realloc-loop-in-must_strcat_pid.patch
CommitLineData
0d386a51
WB
1From cc1d9baadd760a3e6fc757d31569fbf46ad37dbd Mon Sep 17 00:00:00 2001
2From: Wolfgang Bumiller <w.bumiller@proxmox.com>
3Date: Thu, 7 Jan 2016 11:32:59 +0100
4Subject: [PATCH lxcfs 3/5] fix leak in realloc loop in must_strcat_pid
5
6If the first realloc() call fails then 'd' becomes NULL,
7subsequent realloc() retries will behave like malloc() and
8the the original src pointer is never freed. Further more
9the newly allocated data then contains uninitialized data
10where the previous pids had been stored.
11Avoid this by passing the the original pointer from '*src'
12to realloc().
13
14Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
15---
16 lxcfs.c | 2 +-
17 1 file changed, 1 insertion(+), 1 deletion(-)
18
19diff --git a/lxcfs.c b/lxcfs.c
20index 8605000..d738e79 100644
21--- a/lxcfs.c
22+++ b/lxcfs.c
23@@ -87,7 +87,7 @@ static void must_strcat_pid(char **src, size_t *sz, size_t *asz, pid_t pid)
24 *asz = BUF_RESERVE_SIZE;
25 } else if (tmplen + *sz + 1 >= *asz) {
26 do {
27- d = realloc(d, *asz + BUF_RESERVE_SIZE);
28+ d = realloc(*src, *asz + BUF_RESERVE_SIZE);
29 } while (!d);
30 *src = d;
31 *asz += BUF_RESERVE_SIZE;
32--
332.1.4
34