From: bitblt Date: Sat, 7 Dec 1996 09:00:18 +0000 (+0000) Subject: ftpd now eventually times out if a ftp client does: X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=c5d07883a34bbdfafdd737fc1da2d70b73c3b9b0;p=openbsd ftpd now eventually times out if a ftp client does: pasv list and then crashes. The timeout should only apply the the accept(), so that transfers can take as long as necessary to complete. Thanks to Theo for moving toolong() to extern.h so that it can be used in ftpd.c as well as in ftpcmd.y. --- diff --git a/libexec/ftpd/extern.h b/libexec/ftpd/extern.h index 9f825d7baf1..23dbb82fbc0 100644 --- a/libexec/ftpd/extern.h +++ b/libexec/ftpd/extern.h @@ -65,3 +65,4 @@ void store __P((char *, char *, int)); void upper __P((char *)); void user __P((char *)); void yyerror __P((char *)); +void toolong __P((int)); diff --git a/libexec/ftpd/ftpcmd.y b/libexec/ftpd/ftpcmd.y index da68aedae6e..95f11b64203 100644 --- a/libexec/ftpd/ftpcmd.y +++ b/libexec/ftpd/ftpcmd.y @@ -845,7 +845,6 @@ static void help __P((struct tab *, char *)); static struct tab * lookup __P((struct tab *, char *)); static void sizecmd __P((char *)); -static void toolong __P((int)); static int yylex __P((void)); static struct tab * @@ -941,7 +940,7 @@ getline(s, n, iop) return (s); } -static void +void toolong(signo) int signo; { diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c index 76d3b2811ab..6376883dc97 100644 --- a/libexec/ftpd/ftpd.c +++ b/libexec/ftpd/ftpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ftpd.c,v 1.25 1996/12/03 03:07:17 deraadt Exp $ */ +/* $OpenBSD: ftpd.c,v 1.26 1996/12/07 09:00:22 bitblt Exp $ */ /* $NetBSD: ftpd.c,v 1.15 1995/06/03 22:46:47 mycroft Exp $ */ /* @@ -1114,7 +1114,10 @@ dataconn(name, size, mode) struct sockaddr_in from; int s, fromlen = sizeof(from); + signal (SIGALRM, toolong); + (void) alarm ((unsigned) timeout); s = accept(pdata, (struct sockaddr *)&from, &fromlen); + (void) alarm (0); if (s < 0) { reply(425, "Can't open data connection."); (void) close(pdata);