1
0
Fork 0
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:
Johnothan King 2020-08-26 14:19:51 -07:00 committed by GitHub
parent e08ca80d15
commit 8f813bb0a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -980,9 +980,9 @@ static int canexecute(Shell_t *shp,register char *path, int isfun)
errno = EISDIR;
else if((statb.st_mode&S_IXALL)==S_IXALL || sh_access(path,X_OK)>=0)
return(fd);
err:
if(isfun && fd>=0)
sh_close(fd);
err:
return(-1);
}