diff options
author | Moritz Jodeit <moritz@cvs.openbsd.org> | 2008-09-13 12:04:50 +0000 |
---|---|---|
committer | Moritz Jodeit <moritz@cvs.openbsd.org> | 2008-09-13 12:04:50 +0000 |
commit | 34c5d18ff489821d7b917fcdf03b4c6494724233 (patch) | |
tree | ac240852250ca061aa41eabc647f34bb5c1a70b5 /libexec/ftpd/ftpcmd.y | |
parent | b74f788341c9f9a6e35ebbdcdc35a039bdb2ed6c (diff) |
Fix minor bug in the previous commit, which could hang the
current session, when the last character of an overly long line
was a newline character. Additionally reply with
500 "Command too long" for commands, which are too large.
Issue found and proposed fix by Luke Mewburn <lukem@NetBSD.org>.
ok millert@
Diffstat (limited to 'libexec/ftpd/ftpcmd.y')
-rw-r--r-- | libexec/ftpd/ftpcmd.y | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/libexec/ftpd/ftpcmd.y b/libexec/ftpd/ftpcmd.y index 1fda0525032..bf62735a8b5 100644 --- a/libexec/ftpd/ftpcmd.y +++ b/libexec/ftpd/ftpcmd.y @@ -1,4 +1,4 @@ -/* $OpenBSD: ftpcmd.y,v 1.51 2008/09/12 16:12:08 moritz Exp $ */ +/* $OpenBSD: ftpcmd.y,v 1.52 2008/09/13 12:04:49 moritz Exp $ */ /* $NetBSD: ftpcmd.y,v 1.7 1996/04/08 19:03:11 jtc Exp $ */ /* @@ -44,7 +44,7 @@ static const char sccsid[] = "@(#)ftpcmd.y 8.3 (Berkeley) 4/6/94"; #else static const char rcsid[] = - "$OpenBSD: ftpcmd.y,v 1.51 2008/09/12 16:12:08 moritz Exp $"; + "$OpenBSD: ftpcmd.y,v 1.52 2008/09/13 12:04:49 moritz Exp $"; #endif #endif /* not lint */ @@ -1144,7 +1144,7 @@ getline(s, n, iop) * This prevents the command to be split up into * multiple commands. */ - while ((c = getc(iop)) != EOF && c != '\n') + while (c != '\n' && (c = getc(iop)) != EOF) ; return (-2); } @@ -1209,8 +1209,9 @@ yylex() reply(221, "You could at least say goodbye."); dologout(0); } else if (n == -2) { - /* Ignore truncated command */ - break; + reply(500, "Command too long."); + alarm(0); + continue; } (void) alarm(0); if ((cp = strchr(cbuf, '\r'))) { |