[PATCH] su: fix use after free in run_shell

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-off-by: Tanish Yadav <devtany@xxxxxxxxx>
---
 login-utils/su-common.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/login-utils/su-common.c b/login-utils/su-common.c
index 242b6ce4e..8cb54e1c1 100644
--- a/login-utils/su-common.c
+++ b/login-utils/su-common.c
@@ -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





[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux