summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Lai <ray@cvs.openbsd.org>2006-11-02 18:21:21 +0000
committerRay Lai <ray@cvs.openbsd.org>2006-11-02 18:21:21 +0000
commitf09390209295738d7ac0691fc7244c2257443829 (patch)
treef1d9684c3032f7f2d92565ed38d7f42e195328e7
parent562933f8594d83fec92095f3d4e9daddd3997fad (diff)
Only check if last three letters are "/sh" if string is at least
three characters long. OK moritz@.
-rw-r--r--bin/ksh/main.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/bin/ksh/main.c b/bin/ksh/main.c
index 3bf7555d41b..1ea14423b3e 100644
--- a/bin/ksh/main.c
+++ b/bin/ksh/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.41 2006/04/10 14:38:59 jaredy Exp $ */
+/* $OpenBSD: main.c,v 1.42 2006/11/02 18:21:20 ray Exp $ */
/*
* startup, main loop, environments and error handling
@@ -175,8 +175,9 @@ main(int argc, char *argv[])
#endif /* POSIXLY_CORRECT */
/* Check to see if we're /bin/sh. */
- if (!strcmp(&kshname[strlen(kshname) - 3], "/sh") ||
- !strcmp(kshname, "sh") || !strcmp(kshname, "-sh")) {
+ if (!strcmp(kshname, "sh") || !strcmp(kshname, "-sh") ||
+ (strlen(kshname) >= 3 &&
+ !strcmp(&kshname[strlen(kshname) - 3], "/sh"))) {
Flag(FSH) = 1;
version_param = "SH_VERSION";
}