From b2fed5a66db65667013f7d518166813123f15feb Mon Sep 17 00:00:00 2001 From: Till Maas Date: Mar 28 2010 10:09:39 +0000 Subject: rediff hardening write patch --- diff --git a/tmux-1.0-06_hardening_write_return.diff b/tmux-1.0-06_hardening_write_return.diff deleted file mode 100644 index 74de4e6..0000000 --- a/tmux-1.0-06_hardening_write_return.diff +++ /dev/null @@ -1,61 +0,0 @@ -diff --git a/tty.c b/tty.c -index 9d30ed9..2535bf3 100644 ---- a/tty.c -+++ b/tty.c -@@ -283,7 +283,8 @@ tty_free(struct tty *tty) - 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 -@@ -316,7 +317,9 @@ tty_puts(struct tty *tty, const char *s) - 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 -@@ -342,7 +345,8 @@ tty_putc(struct tty *tty, u_char ch) - } - - if (tty->log_fd != -1) -- write(tty->log_fd, &ch, 1); -+ if (write(tty->log_fd, &ch, 1) == -1) -+ fatal("write failed"); - } - - void -@@ -355,7 +359,9 @@ tty_pututf8(struct tty *tty, const struct grid_utf8 *gu) - 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"); -+ - } - - tty->cx += gu->width; -diff --git a/window.c b/window.c -index f4be17d..318d2e9 100644 ---- a/window.c -+++ b/window.c -@@ -516,7 +516,9 @@ window_pane_spawn(struct window_pane *wp, const char *cmd, const char *shell, - 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"); diff --git a/tmux-1.2-writehard.patch b/tmux-1.2-writehard.patch new file mode 100644 index 0000000..a7d3be4 --- /dev/null +++ b/tmux-1.2-writehard.patch @@ -0,0 +1,57 @@ +diff -up tmux-1.2/tty.c.writehard tmux-1.2/tty.c +--- tmux-1.2/tty.c.writehard 2010-03-08 15:53:49.000000000 +0100 ++++ tmux-1.2/tty.c 2010-03-28 12:01:49.335023195 +0200 +@@ -300,7 +300,8 @@ tty_free(struct tty *tty) + 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 +@@ -333,7 +334,8 @@ tty_puts(struct tty *tty, const char *s) + bufferevent_write(tty->event, 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 +@@ -359,7 +361,8 @@ tty_putc(struct tty *tty, u_char ch) + } + + if (tty->log_fd != -1) +- write(tty->log_fd, &ch, 1); ++ if (write(tty->log_fd, &ch, 1) == -1) ++ fatal("write failed"); + } + + void +@@ -370,7 +373,8 @@ tty_pututf8(struct tty *tty, const struc + size = grid_utf8_size(gu); + bufferevent_write(tty->event, gu->data, size); + if (tty->log_fd != -1) +- write(tty->log_fd, gu->data, size); ++ if(write(tty->log_fd, gu->data, size) == -1) ++ fatal("write failed"); + tty->cx += gu->width; + } + +diff -up tmux-1.2/window.c.writehard tmux-1.2/window.c +--- tmux-1.2/window.c.writehard 2010-02-08 19:10:07.000000000 +0100 ++++ tmux-1.2/window.c 2010-03-28 12:03:07.316900726 +0200 +@@ -518,7 +518,9 @@ window_pane_spawn(struct window_pane *wp + 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"); diff --git a/tmux.spec b/tmux.spec index b507ef7..ba648f7 100644 --- a/tmux.spec +++ b/tmux.spec @@ -15,7 +15,9 @@ Source0: http://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar. Patch0: tmux-1.0-02_fix_wrong_location.diff Patch1: tmux-1.0-03_proper_socket_handling.diff Patch2: tmux-1.0-04_dropping_unnecessary_privileges.diff -#Patch3: tmux-1.0-06_hardening_write_return.diff +# 2010-03-28: Submitted upstream: +# https://sourceforge.net/tracker/?func=detail&aid=2977945&group_id=200378&atid=973264 +Patch3: tmux-1.2-writehard.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: ncurses-devel @@ -32,7 +34,7 @@ as GNU Screen. %patch0 -p1 -b .location %patch1 -p1 -b .sockethandling %patch2 -p1 -b .dropprivs -#%patch3 -p1 -b .writehard +%patch3 -p1 -b .writehard %build %configure @@ -61,6 +63,7 @@ getent group tmux >/dev/null || groupadd -r tmux %changelog * Sun Mar 28 2010 Sven Lankes 1.2-1 - New upstream release +- rediff writehard patch * Mon Nov 09 2009 Sven Lankes 1.1-1 - New upstream release