From 59e7366036ff5a9352dd7d2db539acc9648bf218 Mon Sep 17 00:00:00 2001 From: tg Date: Fri, 9 Oct 2015 15:28:20 +0000 Subject: [PATCH] a bit more careful, even if probably unnecessary --- exec.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/exec.c b/exec.c index c49c6be..2b3a612 100644 --- a/exec.c +++ b/exec.c @@ -3,7 +3,7 @@ /*- * Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, * 2011, 2012, 2013, 2014, 2015 - * mirabilos + * mirabilos * * Provided that these terms and disclaimer and all copyright notices * are retained or reproduced in an accompanying document, permission @@ -23,7 +23,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.163 2015/09/06 19:46:59 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.164 2015/10/09 15:28:20 tg Exp $"); #ifndef MKSH_DEFAULT_EXECSHELL #define MKSH_DEFAULT_EXECSHELL MKSH_UNIXROOT "/bin/sh" @@ -1266,9 +1266,13 @@ search_access(const char *fn, int mode) /* file does not exist */ return (ENOENT); /* LINTED use of access */ - if (access(fn, mode) < 0) + if (access(fn, mode) < 0) { /* file exists, but we can't access it */ - return (errno); + int eno; + + eno = errno; + return (eno ? eno : EACCES); + } if (mode == X_OK && (!S_ISREG(sb.st_mode) || !(sb.st_mode & (S_IXUSR|S_IXGRP|S_IXOTH)))) /* access(2) may say root can execute everything */