mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-15 04:32:24 +00:00
Fix a file descriptor leak when fstat errors out with EIO (#120)
src/cmd/ksh93/sh/path.c: canexecute(): - Close file descriptors inside of the err label. This fixes a file descriptor leak that occurs when open succeeds but fstat fails with EIO. The previous code only returned -1 after 'goto err', leaving the opened file descriptor inaccessible. This bugfix was backported from ksh2020: https://github.com/att/ast/commit/55cad1d
This commit is contained in:
parent
e08ca80d15
commit
8f813bb0a3
1 changed files with 1 additions and 1 deletions
|
@ -980,9 +980,9 @@ static int canexecute(Shell_t *shp,register char *path, int isfun)
|
||||||
errno = EISDIR;
|
errno = EISDIR;
|
||||||
else if((statb.st_mode&S_IXALL)==S_IXALL || sh_access(path,X_OK)>=0)
|
else if((statb.st_mode&S_IXALL)==S_IXALL || sh_access(path,X_OK)>=0)
|
||||||
return(fd);
|
return(fd);
|
||||||
|
err:
|
||||||
if(isfun && fd>=0)
|
if(isfun && fd>=0)
|
||||||
sh_close(fd);
|
sh_close(fd);
|
||||||
err:
|
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue