Blame SOURCES/ksh-20120801-cdfix2.patch
|
|
1a53a7 |
diff -up ksh-20120801/src/cmd/ksh93/bltins/cd_pwd.c.cdfix2 ksh-20120801/src/cmd/ksh93/bltins/cd_pwd.c
|
|
|
1a53a7 |
--- ksh-20120801/src/cmd/ksh93/bltins/cd_pwd.c.cdfix2 2013-02-01 16:46:50.441771371 +0100
|
|
|
1a53a7 |
+++ ksh-20120801/src/cmd/ksh93/bltins/cd_pwd.c 2013-02-01 16:57:43.241784024 +0100
|
|
|
1a53a7 |
@@ -61,6 +61,7 @@ int sh_diropenat(Shell_t *shp, int dir,
|
|
|
1a53a7 |
{
|
|
|
1a53a7 |
int fd,shfd;
|
|
|
1a53a7 |
int savederrno=errno;
|
|
|
1a53a7 |
+ struct stat fs;
|
|
|
1a53a7 |
#ifndef AT_FDCWD
|
|
|
1a53a7 |
NOT_USED(dir);
|
|
|
1a53a7 |
#endif
|
|
|
1a53a7 |
@@ -133,6 +134,13 @@ int sh_diropenat(Shell_t *shp, int dir,
|
|
|
1a53a7 |
|
|
|
1a53a7 |
if(fd < 0)
|
|
|
1a53a7 |
return fd;
|
|
|
1a53a7 |
+
|
|
|
1a53a7 |
+ if (!fstat(fd, &fs) && !S_ISDIR(fs.st_mode))
|
|
|
1a53a7 |
+ {
|
|
|
1a53a7 |
+ close(fd);
|
|
|
1a53a7 |
+ errno = ENOTDIR;
|
|
|
1a53a7 |
+ return -1;
|
|
|
1a53a7 |
+ }
|
|
|
1a53a7 |
|
|
|
1a53a7 |
/* Move fd to a number > 10 and *register* the fd number with the shell */
|
|
|
1a53a7 |
shfd = sh_fcntl(fd, F_dupfd_cloexec, 10);
|