From 9a76d32b2b29b832ac35d0b0f3cae4819fe9ca15 Mon Sep 17 00:00:00 2001 From: ume Date: Mon, 10 Jul 2000 10:00:20 +0000 Subject: [PATCH] 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. --- lib/libftpio/ftpio.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/libftpio/ftpio.c b/lib/libftpio/ftpio.c index 0c5c0efb945a..d4e4a9e577a4 100644 --- a/lib/libftpio/ftpio.c +++ b/lib/libftpio/ftpio.c @@ -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