Skip to contentSkip to conversation

su: fix use after free in run_shell

PATCH Applied Tanish Yadav 2 participants 2 messages Mar 4, 2024 – Mar 5, 2024 Util-Linux package

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 su: fix use after free in run_shell

Do not free tmp for non login branch as basename may return a pointer to some part of it.

---
 login-utils/su-common.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
login-utils/su-common.c +0 -0
index 242b6ce4e..8cb54e1c1 100644
@@ -851,10 +851,10 @@ static void run_shell(
		arg0[0] = '-';
		strcpy(arg0 + 1, shell_basename);
		args[0] = arg0;
+		free(tmp);
	} else {

- args[0] = basename(tmp);
- }
- free(tmp);
+ args[0] = basename(tmp);
+ }

	if (su->fast_startup)
		args[argno++] = "-f";

--
2.44.0

maintainer Applied
#1 lore raw
Quoted 2 lines · Tanish Yadav
 login-utils/su-common.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Applied, thanks.

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com