fix embarassing pasto and OS/2 UNC logic; thanks komh!

This commit is contained in:
tg
2016-11-12 03:54:48 +00:00
parent 6d5496a81c
commit 7d387fd54e
2 changed files with 9 additions and 12 deletions

4
exec.c
View File

@ -23,7 +23,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.186 2016/11/11 23:31:34 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/exec.c,v 1.187 2016/11/12 03:54:48 tg Exp $");
#ifndef MKSH_DEFAULT_EXECSHELL #ifndef MKSH_DEFAULT_EXECSHELL
#define MKSH_DEFAULT_EXECSHELL MKSH_UNIXROOT "/bin/sh" #define MKSH_DEFAULT_EXECSHELL MKSH_UNIXROOT "/bin/sh"
@ -1242,7 +1242,7 @@ search_access(const char *fn, int mode)
} }
#ifdef __OS2__ #ifdef __OS2__
/* treat all files as executable on OS/2 */ /* treat all files as executable on OS/2 */
sb.st_mode &= S_IXUSR | S_IXGRP | S_IXOTH; sb.st_mode |= S_IXUSR | S_IXGRP | S_IXOTH;
#endif #endif
if (mode == X_OK && (!S_ISREG(sb.st_mode) || if (mode == X_OK && (!S_ISREG(sb.st_mode) ||
!(sb.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))) !(sb.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))))

17
misc.c
View File

@ -30,7 +30,7 @@
#include <grp.h> #include <grp.h>
#endif #endif
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.249 2016/11/11 23:31:35 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/misc.c,v 1.250 2016/11/12 03:54:48 tg Exp $");
#define KSH_CHVT_FLAG #define KSH_CHVT_FLAG
#ifdef MKSH_SMALL #ifdef MKSH_SMALL
@ -1541,12 +1541,11 @@ do_realpath(const char *upath)
/* symlink target is an absolute path */ /* symlink target is an absolute path */
xp = Xstring(xs, xp); xp = Xstring(xs, xp);
beginning_of_a_pathname: beginning_of_a_pathname:
/* assert: (ip == ipath)[0] == '/' */ /* assert: mksh_cdirsep((ip == ipath)[0]) */
/* assert: xp == xs.beg => start of path */ /* assert: xp == xs.beg => start of path */
/* exactly two leading slashes? (SUSv4 3.266) */ /* exactly two leading slashes? (SUSv4 3.266) */
/* @komh do NOT use mksh_cdirsep() here */ if (ip[1] == ip[0] && !mksh_cdirsep(ip[2])) {
if (ip[1] == '/' && ip[2] != '/') {
/* keep them, e.g. for UNC pathnames */ /* keep them, e.g. for UNC pathnames */
Xput(xs, xp, '/'); Xput(xs, xp, '/');
} }
@ -1711,15 +1710,13 @@ simplify_path(char *p)
case 0: case 0:
return; return;
case '/': case '/':
/* exactly two leading slashes? (SUSv4 3.266) */
/* @komh no mksh_cdirsep() here! */
if (p[1] == '/' && p[2] != '/')
/* keep them, e.g. for UNC pathnames */
++p;
#ifdef __OS2__ #ifdef __OS2__
/* FALLTHROUGH */
case '\\': case '\\':
#endif #endif
/* exactly two leading slashes? (SUSv4 3.266) */
if (p[1] == p[0] && !mksh_cdirsep(p[2]))
/* keep them, e.g. for UNC pathnames */
++p;
needslash = true; needslash = true;
break; break;
default: default: