about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--Src/Modules/files.c3
-rw-r--r--Src/Modules/mapfile.c6
-rw-r--r--Src/Modules/zftp.c5
-rw-r--r--Src/builtin.c12
-rw-r--r--Src/exec.c3
-rw-r--r--Src/hist.c4
-rw-r--r--Src/utils.c3
8 files changed, 28 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 054ebd245..34d3618d8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-03-14  Wayne Davison  <wayned@users.sourceforge.net>
+
+	* 26735: Src/Modules/files.c, Src/Modules/mapfile.c,
+	Src/Modules/zftp.c, Src/builtin.c, Src/exec.c,
+	Src/hist.c, Src/utils.c: improved return-value checking.
+
 2009-03-14  Peter Stephenson  <p.w.stephenson@ntlworld.com>
 
 	* users/13910: Src/jobs.c: spawnjob() should output job
@@ -11403,5 +11409,5 @@
 
 *****************************************************
 * This is used by the shell to define $ZSH_PATCHLEVEL
-* $Revision: 1.4616 $                         
+* $Revision: 1.4617 $
 *****************************************************
diff --git a/Src/Modules/files.c b/Src/Modules/files.c
index f22b23fb7..0b991c556 100644
--- a/Src/Modules/files.c
+++ b/Src/Modules/files.c
@@ -428,7 +428,8 @@ recursivecmd(char *nam, int opt_noerr, int opt_recurse, int opt_safe,
     if ((err & 2) && ds.dirfd >= 0 && restoredir(&ds) && zchdir(pwd)) {
 	zsfree(pwd);
 	pwd = ztrdup("/");
-	chdir(pwd);
+	if (chdir(pwd) < 0)
+	    zwarn("failed to chdir(%s): %e", pwd, errno);
     }
     if (ds.dirfd >= 0)
 	close(ds.dirfd);
diff --git a/Src/Modules/mapfile.c b/Src/Modules/mapfile.c
index d825c7faa..422c7077c 100644
--- a/Src/Modules/mapfile.c
+++ b/Src/Modules/mapfile.c
@@ -92,7 +92,8 @@ setpmmapfile(Param pm, char *value)
 	 * First we need to make sure the file is long enough for
 	 * when we msync.  On AIX, at least, we just get zeroes otherwise.
 	 */
-	ftruncate(fd, len);
+	if (ftruncate(fd, len) < 0)
+	    zwarn("ftruncate failed: %e", errno);
 	memcpy(mmptr, value, len);
 #ifndef MS_SYNC
 #define MS_SYNC 0
@@ -102,7 +103,8 @@ setpmmapfile(Param pm, char *value)
 	 * Then we need to truncate again, since mmap() always maps complete
 	 * pages.  Honestly, I tried it without, and you need both.
 	 */
-	ftruncate(fd, len);
+	if (ftruncate(fd, len) < 0)
+	    zwarn("ftruncate failed: %e", errno);
 	munmap(mmptr, len);
     }
 #else /* don't USE_MMAP */
diff --git a/Src/Modules/zftp.c b/Src/Modules/zftp.c
index 12a9f0de2..0dc94866a 100644
--- a/Src/Modules/zftp.c
+++ b/Src/Modules/zftp.c
@@ -2043,8 +2043,9 @@ zfgetinfo(char *prompt, int noecho)
 	fflush(stderr);
     }
 
-    fgets(instr, 256, stdin);
-    if (instr[len = strlen(instr)-1] == '\n')
+    if (fgets(instr, 256, stdin) == NULL)
+	instr[len = 0] = '\0';
+    else if (instr[len = strlen(instr)-1] == '\n')
 	instr[len] = '\0';
 
     strret = dupstring(instr);
diff --git a/Src/builtin.c b/Src/builtin.c
index 050101f5e..95aca06fd 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -795,16 +795,16 @@ bin_cd(char *nam, char **argv, Options ops, int func)
 	setjobpwd();
 	zsfree(pwd);
 	pwd = metafy(zgetcwd(), -1, META_DUP);
-    } else if (stat(".", &st2) < 0)
-	chdir(unmeta(pwd));
-    else if (st1.st_ino != st2.st_ino || st1.st_dev != st2.st_dev) {
+    } else if (stat(".", &st2) < 0) {
+	if (chdir(unmeta(pwd)) < 0)
+	    zwarn("unable to chdir(%s): %e", pwd, errno);
+    } else if (st1.st_ino != st2.st_ino || st1.st_dev != st2.st_dev) {
 	if (chasinglinks) {
 	    setjobpwd();
 	    zsfree(pwd);
 	    pwd = metafy(zgetcwd(), -1, META_DUP);
-	} else {
-	    chdir(unmeta(pwd));
-	}
+	} else if (chdir(unmeta(pwd)) < 0)
+	    zwarn("unable to chdir(%s): %e", pwd, errno);
     }
     unqueue_signals();
     return 0;
diff --git a/Src/exec.c b/Src/exec.c
index ed7c08759..4f15ebefa 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -2722,7 +2722,8 @@ execcmd(Estate state, int input, int output, int how, int last1)
 #ifdef HAVE_NICE
 	/* Check if we should run background jobs at a lower priority. */
 	if ((how & Z_ASYNC) && isset(BGNICE))
-	    nice(5);
+	    if (nice(5) < 0)
+		zwarn("nice(5) failed: %e", errno);
 #endif /* HAVE_NICE */
 
     } else if (is_cursh) {
diff --git a/Src/hist.c b/Src/hist.c
index 38ceac30a..637976de7 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -2291,9 +2291,9 @@ savehistfile(char *fn, int err, int writeflags)
 #ifdef HAVE_FCHMOD
 	    if (old_exists && out) {
 #ifdef HAVE_FCHOWN
-		fchown(fileno(out), sb.st_uid, sb.st_gid);
+		if (fchown(fileno(out), sb.st_uid, sb.st_gid) < 0) {} /* IGNORE FAILURE */
 #endif
-		fchmod(fileno(out), sb.st_mode);
+		if (fchmod(fileno(out), sb.st_mode) < 0) {} /* IGNORE FAILURE */
 	    }
 #endif
 	}
diff --git a/Src/utils.c b/Src/utils.c
index 7a983d48d..340ceb857 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -5422,7 +5422,8 @@ lchdir(char const *path, struct dirsav *d, int hard)
     }
 #ifdef HAVE_LSTAT
     if (*path == '/')
-	chdir("/");
+	if (chdir("/") < 0)
+	    zwarn("failed to chdir(/): %e", errno);
     for(;;) {
 	while(*path == '/')
 	    path++;