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:
parent
53039364ea
commit
9a76d32b2b
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user