su: fix use after free in run_shell
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.
Signed-off-by Tanish Yadav <[email protected]>
--- login-utils/su-common.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
login-utils/su-common.c +0 -0
@@ -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
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