summaryrefslogtreecommitdiff
path: root/source/ap/ksh93/patches/ksh-20120801-noexeccdfix.patch
blob: 47128e09bebb3d2f9ecc544ebb463bacdd765659 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
From b8260293a8ed7849a358291faae7b58f4a05dcc9 Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
Date: Mon, 10 Nov 2014 18:23:34 +0100
Subject: [PATCH] Resolves: #1160923 - handle failure of fchdir()

... and chdir()
---
 src/cmd/ksh93/bltins/cd_pwd.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/cmd/ksh93/bltins/cd_pwd.c b/src/cmd/ksh93/bltins/cd_pwd.c
index a972da6..c20959c 100644
--- a/src/cmd/ksh93/bltins/cd_pwd.c
+++ b/src/cmd/ksh93/bltins/cd_pwd.c
@@ -329,18 +329,20 @@ int	b_cd(int argc, char *argv[],Shbltin_t *context)
 		if(newdirfd >=0)
 		{
 			/* chdir for directories on HSM/tapeworms may take minutes */
-			if(fchdir(newdirfd) >= 0)
+			if((rval=fchdir(newdirfd)) >= 0)
 			{
 				if(shp->pwdfd >= 0)
 					sh_close(shp->pwdfd);
 				shp->pwdfd=newdirfd;
 				goto success;
 			}
+			else
+				sh_close(newdirfd);
 		}
 #ifndef O_SEARCH
 		else
 		{
-			if(chdir(dir) >=0)
+			if((rval=chdir(dir)) >=0)
 			{
 				if(shp->pwdfd >= 0)
 				{
-- 
2.1.0