diff --git a/src/ChangeLog b/src/ChangeLog index d9731248..17d0817b 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2014-11-19 Tim Ruehsen + + * ftp-basic.c (ftp_epsv): Fix loop check + + Reported-by: Coverity scanner + 2014-11-19 Darshit Shah * exits.c (get_status_for_err): GATEWAYTIMEOUT is a Server Error and Wget's diff --git a/src/ftp-basic.c b/src/ftp-basic.c index b6e67e26..83cc447b 100644 --- a/src/ftp-basic.c +++ b/src/ftp-basic.c @@ -784,15 +784,13 @@ ftp_epsv (int csock, ip_address *ip, int *port) } /* Finally, get the port number */ - tport = 0; - for (i = 1; c_isdigit (*s); s++) - { - if (i > 5) - { - xfree (respline); - return FTPINVPASV; - } + for (tport = 0, i = 0; i < 5 && c_isdigit (*s); i++, s++) tport = (*s - '0') + 10 * tport; + + if (i >= 5) + { + xfree (respline); + return FTPINVPASV; } /* Make sure that the response terminates correcty */