diff options
Diffstat (limited to 'crypto/heimdal/appl/ftp/ftpd/ftpcmd.y')
-rw-r--r-- | crypto/heimdal/appl/ftp/ftpd/ftpcmd.y | 71 |
1 files changed, 36 insertions, 35 deletions
diff --git a/crypto/heimdal/appl/ftp/ftpd/ftpcmd.y b/crypto/heimdal/appl/ftp/ftpd/ftpcmd.y index 2c90987d65d7..9c5fa4c37d83 100644 --- a/crypto/heimdal/appl/ftp/ftpd/ftpcmd.y +++ b/crypto/heimdal/appl/ftp/ftpd/ftpcmd.y @@ -43,14 +43,17 @@ %{ #include "ftpd_locl.h" -RCSID("$Id: ftpcmd.y,v 1.61 2001/08/05 06:39:29 assar Exp $"); +RCSID("$Id: ftpcmd.y,v 1.61.10.2 2004/08/20 15:15:46 lha Exp $"); off_t restart_point; +static int hasyyerrored; + + static int cmd_type; static int cmd_form; static int cmd_bytesz; -char cbuf[2048]; +char cbuf[64*1024]; char *fromname; struct tab { @@ -303,15 +306,6 @@ cmd } | sTAT CRLF { - if(oobflag){ - if (file_size != (off_t) -1) - reply(213, "Status: %lu of %lu bytes transferred", - (unsigned long)byte_count, - (unsigned long)file_size); - else - reply(213, "Status: %lu bytes transferred", - (unsigned long)byte_count); - }else statcmd(); } | DELE SP pathname CRLF check_login_no_guest @@ -337,13 +331,7 @@ cmd } | ABOR CRLF { - if(oobflag){ - reply(426, "Transfer aborted. Data connection closed."); - reply(226, "Abort successful"); - oobflag = 0; - longjmp(urgcatch, 1); - }else - reply(225, "ABOR command successful."); + reply(225, "ABOR command successful."); } | CWD CRLF check_login { @@ -914,8 +902,6 @@ check_secure : /* empty */ %% -extern jmp_buf errcatch; - #define CMD 0 /* beginning of command */ #define ARGS 1 /* expect miscellaneous arguments */ #define STR1 2 /* expect SP followed by STRING */ @@ -1034,15 +1020,13 @@ ftpd_getline(char *s, int n) char *cs; cs = s; -/* tmpline may contain saved command from urgent mode interruption */ + + /* might still be data within the security MIC/CONF/ENC */ if(ftp_command){ - strlcpy(s, ftp_command, n); - if (debug) - syslog(LOG_DEBUG, "command: %s", s); -#ifdef XXX - fprintf(stderr, "%s\n", s); -#endif - return s; + strlcpy(s, ftp_command, n); + if (debug) + syslog(LOG_DEBUG, "command: %s", s); + return s; } while ((c = getc(stdin)) != EOF) { c &= 0377; @@ -1127,6 +1111,8 @@ yylex(void) switch (state) { case CMD: + hasyyerrored = 0; + signal(SIGALRM, toolong); alarm((unsigned) ftpd_timeout); if (ftpd_getline(cbuf, sizeof(cbuf)-1) == NULL) { @@ -1135,7 +1121,7 @@ yylex(void) } alarm(0); #ifdef HAVE_SETPROCTITLE - if (strncasecmp(cbuf, "PASS", 4) != NULL) + if (strncasecmp(cbuf, "PASS", 4) != 0) setproctitle("%s: %s", proctitle, cbuf); #endif /* HAVE_SETPROCTITLE */ if ((cp = strchr(cbuf, '\r'))) { @@ -1154,8 +1140,8 @@ yylex(void) if (p != 0) { if (p->implemented == 0) { nack(p->name); - longjmp(errcatch,0); - /* NOTREACHED */ + hasyyerrored = 1; + break; } state = p->state; yylval.s = p->name; @@ -1180,8 +1166,8 @@ yylex(void) if (p->implemented == 0) { state = CMD; nack(p->name); - longjmp(errcatch,0); - /* NOTREACHED */ + hasyyerrored = 1; + break; } state = p->state; yylval.s = p->name; @@ -1329,12 +1315,27 @@ yylex(void) default: fatal("Unknown state in scanner."); } - yyerror((char *) 0); + yyerror(NULL); state = CMD; - longjmp(errcatch,0); + return (0); } } +/* ARGSUSED */ +void +yyerror(char *s) +{ + char *cp; + + if (hasyyerrored) + return; + + if ((cp = strchr(cbuf,'\n'))) + *cp = '\0'; + reply(500, "'%s': command not understood.", cbuf); + hasyyerrored = 1; +} + static char * copy(char *s) { |