Blame SOURCES/ksh-20120801-cdfix2.patch

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