[git commit] ash: do not truncate failed tilde expansion on unknown user names

Denys Vlasenko vda.linux at googlemail.com
Tue Mar 1 09:10:22 UTC 2022


commit: https://git.busybox.net/busybox/commit/?id=5fe20cf3212fbada86fb75cf13064caed6a5f3a9
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

Do not skip over "*p = c;" statement.

Testcase: echo ~~nouser/qwe

function                                             old     new   delta
argstr                                              1396    1406     +10

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 shell/ash.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/shell/ash.c b/shell/ash.c
index 44ec2eafd..ef4a47afe 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -6532,9 +6532,7 @@ exptilde(char *startp, int flag)
 		home = lookupvar("HOME");
 	} else {
 		pw = getpwnam(name);
-		if (pw == NULL)
-			goto lose;
-		home = pw->pw_dir;
+		home = pw ? pw->pw_dir : NULL;
 	}
 	*p = c;
 	if (!home)


More information about the busybox-cvs mailing list