Lines 980-986
static struct tab *lookup(struct tab *p,
Link Here
|
980 |
/* |
980 |
/* |
981 |
* getline - a hacked up version of fgets to ignore TELNET escape codes. |
981 |
* getline - a hacked up version of fgets to ignore TELNET escape codes. |
982 |
*/ |
982 |
*/ |
983 |
char * ftpd_getline(char *s, int n, FILE *iop) |
983 |
int ftpd_getline(char *s, int n, FILE *iop) |
984 |
{ |
984 |
{ |
985 |
int c; |
985 |
int c; |
986 |
register char *cs; |
986 |
register char *cs; |
Lines 995-1001
char * ftpd_getline(char *s, int n, FILE
Link Here
|
995 |
if (debug) |
995 |
if (debug) |
996 |
syslog(LOG_DEBUG, "command: %s", s); |
996 |
syslog(LOG_DEBUG, "command: %s", s); |
997 |
tmpline[0] = '\0'; |
997 |
tmpline[0] = '\0'; |
998 |
return(s); |
998 |
return(0); |
999 |
} |
999 |
} |
1000 |
if (c == 0) |
1000 |
if (c == 0) |
1001 |
tmpline[0] = '\0'; |
1001 |
tmpline[0] = '\0'; |
Lines 1037-1047
char * ftpd_getline(char *s, int n, FILE
Link Here
|
1037 |
} |
1037 |
} |
1038 |
} |
1038 |
} |
1039 |
*cs++ = c; |
1039 |
*cs++ = c; |
1040 |
if (--n <= 0 || c == '\n') |
1040 |
if (--n <= 0) { |
|
|
1041 |
/* |
1042 |
* If command doesn't fit into buffer, discard the |
1043 |
* rest of the command and indicate truncation. |
1044 |
* This prevents the command to be split up into |
1045 |
* multiple commands. |
1046 |
*/ |
1047 |
while (c != '\n' && (c = getc(iop)) != EOF) |
1048 |
; |
1049 |
return (-2); |
1050 |
} |
1051 |
if (c == '\n') |
1041 |
break; |
1052 |
break; |
1042 |
} |
1053 |
} |
1043 |
if (c == EOF && cs == s) |
1054 |
if (c == EOF && cs == s) |
1044 |
return (NULL); |
1055 |
return (-1); |
1045 |
*cs++ = '\0'; |
1056 |
*cs++ = '\0'; |
1046 |
if (debug) { |
1057 |
if (debug) { |
1047 |
if (!guest && strncasecmp("pass ", s, 5) == 0) { |
1058 |
if (!guest && strncasecmp("pass ", s, 5) == 0) { |
Lines 1061-1067
char * ftpd_getline(char *s, int n, FILE
Link Here
|
1061 |
syslog(LOG_DEBUG, "command: %.*s", len, s); |
1072 |
syslog(LOG_DEBUG, "command: %.*s", len, s); |
1062 |
} |
1073 |
} |
1063 |
} |
1074 |
} |
1064 |
return (s); |
1075 |
return (0); |
1065 |
} |
1076 |
} |
1066 |
|
1077 |
|
1067 |
void toolong(int signo) |
1078 |
void toolong(int signo) |
Lines 1090-1098
static int yylex(void)
Link Here
|
1090 |
case CMD: |
1101 |
case CMD: |
1091 |
(void) signal(SIGALRM, toolong); |
1102 |
(void) signal(SIGALRM, toolong); |
1092 |
(void) alarm((unsigned) timeout); |
1103 |
(void) alarm((unsigned) timeout); |
1093 |
if (ftpd_getline(cbuf, sizeof(cbuf)-1, stdin)==NULL) { |
1104 |
n = ftpd_getline(cbuf, sizeof(cbuf)-1, stdin); |
|
|
1105 |
if (n == -1) { |
1094 |
reply(221, "You could at least say goodbye."); |
1106 |
reply(221, "You could at least say goodbye."); |
1095 |
dologout(0); |
1107 |
dologout(0); |
|
|
1108 |
} else if (n == -2) { |
1109 |
reply(500, "Command too long."); |
1110 |
alarm(0); |
1111 |
continue; |
1096 |
} |
1112 |
} |
1097 |
(void) alarm(0); |
1113 |
(void) alarm(0); |
1098 |
if ((cp = strchr(cbuf, '\r'))) { |
1114 |
if ((cp = strchr(cbuf, '\r'))) { |