shadow/backport-Plug-econf-memory-leaks.patch
yunjia_w 69dfb82329 backport some patches
Signed-off-by: yunjia_w <yunjia.wang@huawei.com>
2023-08-22 11:22:12 +08:00

43 lines
921 B
Diff

From 8175b1532e4bb1951264e8a6ee5f484137e5306c Mon Sep 17 00:00:00 2001
From: Tobias Stoeckmann <tobias@stoeckmann.org>
Date: Thu, 18 May 2023 17:25:35 +0200
Subject: [PATCH] Plug econf memory leaks
You can see the memory leaks with address sanitizer if shadow is
compiled with `--enable-vendordir=/usr/etc`.
How to reproduce:
1. Prepare a custom shell file as root
```
mkdir -p /etc/shells.d
echo /bin/myshell > /etc/shells.d/custom
```
2. Run chsh as regular user
```
chsh
```
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
---
lib/getdef.c | 2 ++
1 files changed, 2 insertions(+)
diff --git a/lib/getdef.c b/lib/getdef.c
index a2a7e484..763d847a 100644
--- a/lib/getdef.c
+++ b/lib/getdef.c
@@ -522,6 +522,8 @@ static void def_load (void)
* syslog. The tools will just use their default values.
*/
(void)putdef_str (keys[i], value);
+
+ free(value);
}
econf_free (keys);
--
2.27.0