Blame tmux-1.0-06_hardening_write_return.diff

Sven Lankes 73482c
diff --git a/tty.c b/tty.c
Sven Lankes 73482c
index 9d30ed9..2535bf3 100644
Sven Lankes 580ca5
--- a/tty.c
Sven Lankes 580ca5
+++ b/tty.c
Sven Lankes 73482c
@@ -283,7 +283,8 @@ tty_free(struct tty *tty)
Sven Lankes 580ca5
 void
Sven Lankes 580ca5
 tty_raw(struct tty *tty, const char *s)
Sven Lankes 580ca5
 {
Sven Lankes 580ca5
-	write(tty->fd, s, strlen(s));
Sven Lankes 73482c
+    if (write(tty->fd, s, strlen(s)) == -1)
Sven Lankes 73482c
+        fatal("write failed");
Sven Lankes 580ca5
 }
Sven Lankes 580ca5
 
Sven Lankes 580ca5
 void
Sven Lankes 73482c
@@ -316,7 +317,9 @@ tty_puts(struct tty *tty, const char *s)
Sven Lankes 580ca5
 	buffer_write(tty->out, s, strlen(s));
Sven Lankes 580ca5
 
Sven Lankes 580ca5
 	if (tty->log_fd != -1)
Sven Lankes 580ca5
-		write(tty->log_fd, s, strlen(s));
Sven Lankes 73482c
+        if (write(tty->log_fd, s, strlen(s)) == -1)
Sven Lankes 73482c
+            fatal("write failed");
Sven Lankes 73482c
+
Sven Lankes 580ca5
 }
Sven Lankes 580ca5
 
Sven Lankes 580ca5
 void
Sven Lankes 73482c
@@ -342,7 +345,8 @@ tty_putc(struct tty *tty, u_char ch)
Sven Lankes 580ca5
 	}
Sven Lankes 580ca5
 
Sven Lankes 580ca5
 	if (tty->log_fd != -1)
Sven Lankes 580ca5
-		write(tty->log_fd, &ch, 1);
Sven Lankes 73482c
+       if (write(tty->log_fd, &ch, 1) == -1)
Sven Lankes 73482c
+           fatal("write failed");
Sven Lankes 580ca5
 }
Sven Lankes 580ca5
 
Sven Lankes 580ca5
 void
Sven Lankes 73482c
@@ -355,7 +359,9 @@ tty_pututf8(struct tty *tty, const struct grid_utf8 *gu)
Sven Lankes 580ca5
 			break;
Sven Lankes 580ca5
 		buffer_write8(tty->out, gu->data[i]);
Sven Lankes 580ca5
 		if (tty->log_fd != -1)
Sven Lankes 580ca5
-			write(tty->log_fd, &gu->data[i], 1);
Sven Lankes 73482c
+           if (write(tty->log_fd, &gu->data[i], 1) == -1)
Sven Lankes 73482c
+               fatal("write failed");
Sven Lankes 73482c
+
Sven Lankes 580ca5
 	}
Sven Lankes 580ca5
 
Sven Lankes 73482c
 	tty->cx += gu->width;
Sven Lankes 73482c
diff --git a/window.c b/window.c
Sven Lankes 73482c
index f4be17d..318d2e9 100644
Sven Lankes 580ca5
--- a/window.c
Sven Lankes 580ca5
+++ b/window.c
Sven Lankes 73482c
@@ -516,7 +516,9 @@ window_pane_spawn(struct window_pane *wp, const char *cmd, const char *shell,
Sven Lankes 580ca5
 		return (-1);
Sven Lankes 580ca5
 	case 0:
Sven Lankes 580ca5
 		if (chdir(wp->cwd) != 0)
Sven Lankes 580ca5
-			chdir("/");
Sven Lankes 73482c
+           if (chdir("/") <0)
Sven Lankes 73482c
+               fatal("chdir failed");
Sven Lankes 580ca5
+
Sven Lankes 580ca5
 
Sven Lankes 580ca5
 		if (tcgetattr(STDIN_FILENO, &tio2) != 0)
Sven Lankes 580ca5
 			fatal("tcgetattr failed");