tmux/tmux-1.0-06_hardening_write_return.diff
Sven Lankes 580ca581cb - Add debian patches
- Add tmux group for improved socket handling
2009-11-01 18:46:32 +00:00

57 lines
1.1 KiB
Diff

# Harden write and chdir because of ignored return value
--- a/tty.c
+++ b/tty.c
@@ -336,7 +336,8 @@
void
tty_raw(struct tty *tty, const char *s)
{
- write(tty->fd, s, strlen(s));
+ if (write(tty->fd, s, strlen(s)) == -1)
+ fatal("write failed");
}
void
@@ -369,7 +370,8 @@
buffer_write(tty->out, s, strlen(s));
if (tty->log_fd != -1)
- write(tty->log_fd, s, strlen(s));
+ if (write(tty->log_fd, s, strlen(s)) == -1)
+ fatal("write failed");
}
void
@@ -394,7 +396,8 @@
}
if (tty->log_fd != -1)
- write(tty->log_fd, &ch, 1);
+ if (write(tty->log_fd, &ch, 1) == -1)
+ fatal("write failed");
}
void
@@ -407,7 +410,8 @@
break;
buffer_write8(tty->out, gu->data[i]);
if (tty->log_fd != -1)
- write(tty->log_fd, &gu->data[i], 1);
+ if (write(tty->log_fd, &gu->data[i], 1) == -1)
+ fatal("write failed");
}
width = utf8_width(gu->data);
--- a/window.c
+++ b/window.c
@@ -490,7 +490,9 @@
return (-1);
case 0:
if (chdir(wp->cwd) != 0)
- chdir("/");
+ if (chdir("/") <0 )
+ fatal("chdir failed");
+
if (tcgetattr(STDIN_FILENO, &tio2) != 0)
fatal("tcgetattr failed");