diff options
author | Dan Harnett <danh@cvs.openbsd.org> | 2002-06-17 19:33:38 +0000 |
---|---|---|
committer | Dan Harnett <danh@cvs.openbsd.org> | 2002-06-17 19:33:38 +0000 |
commit | bfae27c1c947f622bb9f1e1cc33987d0b3818169 (patch) | |
tree | ddfa9d41dbec8e7c542dc45154c86b1993d349f8 | |
parent | d27320aa6ec1696185c414c78ff94550b5126a50 (diff) |
Initialize SIGALRM handler once in main(), instead of in several
different locations.
This fixes a problem where the SIGALRM handler was being set to an
uninitialized pointer in receive_data(). Originally reported to the
misc@ list by Colin Harford.
ok millert@
-rw-r--r-- | libexec/ftpd/ftpcmd.y | 5 | ||||
-rw-r--r-- | libexec/ftpd/ftpd.c | 13 |
2 files changed, 7 insertions, 11 deletions
diff --git a/libexec/ftpd/ftpcmd.y b/libexec/ftpd/ftpcmd.y index 1b596fc5594..690096505c7 100644 --- a/libexec/ftpd/ftpcmd.y +++ b/libexec/ftpd/ftpcmd.y @@ -1,4 +1,4 @@ -/* $OpenBSD: ftpcmd.y,v 1.39 2002/02/19 17:58:24 mpech Exp $ */ +/* $OpenBSD: ftpcmd.y,v 1.40 2002/06/17 19:33:37 danh Exp $ */ /* $NetBSD: ftpcmd.y,v 1.7 1996/04/08 19:03:11 jtc Exp $ */ /* @@ -47,7 +47,7 @@ #if 0 static char sccsid[] = "@(#)ftpcmd.y 8.3 (Berkeley) 4/6/94"; #else -static char rcsid[] = "$OpenBSD: ftpcmd.y,v 1.39 2002/02/19 17:58:24 mpech Exp $"; +static char rcsid[] = "$OpenBSD: ftpcmd.y,v 1.40 2002/06/17 19:33:37 danh Exp $"; #endif #endif /* not lint */ @@ -1187,7 +1187,6 @@ yylex() switch (state) { case CMD: - (void) signal(SIGALRM, toolong); (void) alarm((unsigned) timeout); if (getline(cbuf, sizeof(cbuf)-1, stdin) == NULL) { reply(221, "You could at least say goodbye."); diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c index 4a7c4014708..abbd44184ac 100644 --- a/libexec/ftpd/ftpd.c +++ b/libexec/ftpd/ftpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ftpd.c,v 1.128 2002/06/09 00:37:37 itojun Exp $ */ +/* $OpenBSD: ftpd.c,v 1.129 2002/06/17 19:33:37 danh Exp $ */ /* $NetBSD: ftpd.c,v 1.15 1995/06/03 22:46:47 mycroft Exp $ */ /* @@ -73,7 +73,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)ftpd.c 8.4 (Berkeley) 4/16/94"; #else -static char rcsid[] = "$OpenBSD: ftpd.c,v 1.128 2002/06/09 00:37:37 itojun Exp $"; +static char rcsid[] = "$OpenBSD: ftpd.c,v 1.129 2002/06/17 19:33:37 danh Exp $"; #endif #endif /* not lint */ @@ -494,6 +494,9 @@ main(argc, argv, envp) sa.sa_handler = lostconn; (void) sigaction(SIGPIPE, &sa, NULL); + sa.sa_handler = toolong; + (void) sigaction(SIGALRM, &sa, NULL); + addrlen = sizeof(ctrl_addr); if (getsockname(0, (struct sockaddr *)&ctrl_addr, &addrlen) < 0) { syslog(LOG_ERR, "getsockname: %m"); @@ -1361,7 +1364,6 @@ dataconn(name, size, mode) union sockunion from; int s, fromlen = sizeof(from); - signal (SIGALRM, toolong); (void) alarm ((unsigned) timeout); s = accept(pdata, (struct sockaddr *)&from, &fromlen); (void) alarm (0); @@ -1621,7 +1623,6 @@ receive_data(instr, outstr) int c; int cnt; char buf[BUFSIZ]; - struct sigaction sa; volatile int bare_lfs = 0; transflag++; @@ -1629,10 +1630,6 @@ receive_data(instr, outstr) case TYPE_I: case TYPE_L: - sigfillset(&sa.sa_mask); - sa.sa_flags = SA_RESTART; - sigaction(SIGALRM, &sa, NULL); - do { (void) alarm ((unsigned) timeout); cnt = read(fileno(instr), buf, sizeof(buf)); |