From bfae27c1c947f622bb9f1e1cc33987d0b3818169 Mon Sep 17 00:00:00 2001 From: Dan Harnett Date: Mon, 17 Jun 2002 19:33:38 +0000 Subject: 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@ --- libexec/ftpd/ftpcmd.y | 5 ++--- 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)); -- cgit v1.2.3