Patch: sysklogd-1.4.1-owl-longjmp.diff from Openwall

From: Solar Designer <solar@openwall.com>

1. Ensures that "len" is not placed in a register and as such can't be
clobbered by longjmp().  With the particular code, it does not really
matter whether it is clobbered or not, but this avoids the gcc warning.

2. Makes endtty() the signal handler only after the variable that
function uses is initialized.  In the original code, the signal
handler was setup too early and if there would be SIGALRM before
control reaches setjmp(), syslogd would segfault (if not worse).

Basically, this is a minor correctness patch.
This commit is contained in:
Joey Schulze 2004-05-04 14:49:23 +00:00
parent dcef709022
commit 3ee89e2c0b

View File

@ -453,6 +453,11 @@ static char sccsid[] = "@(#)syslogd.c 5.27 (Berkeley) 10/10/88";
*
* Thu Apr 29 12:38:39 2004: Solar Designer <solar@openwall.com>
* Applied Openwall paranoia patches to improve crunch_list().
*
* Tue May 4 16:47:30 CEST 2004: Solar Designer <solar@openwall.com>
* Ensure that "len" is not placed in a register, and that the
* endtty() signal handler is not installed too early which could
* cause a segmentation fault or worse.
*/
@ -1905,6 +1910,8 @@ void wallmsg(f, iov)
struct utmp *uptr;
char greetings[200];
(void) &len;
if (reenter++)
return;
@ -1919,7 +1926,6 @@ void wallmsg(f, iov)
if (fork() == 0) {
(void) signal(SIGTERM, SIG_DFL);
(void) alarm(0);
(void) signal(SIGALRM, endtty);
#ifndef SYSV
(void) signal(SIGTTOU, SIG_IGN);
(void) sigsetmask(0);
@ -1965,6 +1971,7 @@ void wallmsg(f, iov)
iov[1].iov_len = 0;
}
if (setjmp(ttybuf) == 0) {
(void) signal(SIGALRM, endtty);
(void) alarm(15);
/* open the terminal */
ttyf = open(p, O_WRONLY|O_NOCTTY);