Separate parsing code of 229 replies from the code for 227 and 228.

Don't assume 227 and 228 replies enclose remote address with parentheses.
This commit is contained in:
Hajimu UMEMOTO 2000-07-10 10:00:20 +00:00
parent b4720b889e
commit 80fe4a43d1
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=62905

View File

@ -867,13 +867,14 @@ ftp_file_op(FTP_t ftp, char *operation, char *file, FILE **fp, char *mode, off_t
} else
cmdstr = "EPSV";
}
while (*q && *q != '(') /* ) */
q++;
if (!*q) {
ftp_close(ftp);
return FAILURE;
}
if (strcmp(cmdstr, "PASV") == 0 || strcmp(cmdstr, "LPSV") == 0) {
while (*q && !isdigit(*q))
q++;
if (!*q) {
ftp_close(ftp);
return FAILURE;
}
q--;
l = (ftp->addrtype == AF_INET ? 6 : 21);
for (i = 0; i < l; i++) {
q++;
@ -893,6 +894,12 @@ ftp_file_op(FTP_t ftp, char *operation, char *file, FILE **fp, char *mode, off_t
} else if (strcmp(cmdstr, "EPSV") == 0) {
int port;
int sinlen;
while (*q && *q != '(') /* ) */
q++;
if (!*q) {
ftp_close(ftp);
return FAILURE;
}
q++;
if (sscanf(q, "%c%c%c%d%c", &addr[0], &addr[1], &addr[2],
&port, &addr[3]) != 5