Blame SOURCES/ksh-20120801-cdfix2.patch

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