Remove all traces of setjmp/longjmp.
Handle those command that is needed in oobhandler, those are ABOR, STAT, ENC, CONF, MIC. add options to turn off insecure OOB handling and document the option Changes inspired by openbsd and netbsd changes but quite diffrent is most places since the code no longer look and is structured the same way. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@14136 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -47,6 +47,9 @@ RCSID("$Id$");
|
||||
|
||||
off_t restart_point;
|
||||
|
||||
static int hasyyerrored;
|
||||
|
||||
|
||||
static int cmd_type;
|
||||
static int cmd_form;
|
||||
static int cmd_bytesz;
|
||||
@@ -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) {
|
||||
@@ -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)
|
||||
{
|
||||
|
Reference in New Issue
Block a user