From 6d2b42cbd049c8e54ec11663c3bea8ddd022c6ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim Rühsen?= Date: Wed, 19 Nov 2014 14:35:40 +0100 Subject: [PATCH] Fix loop check --- src/ChangeLog | 6 ++++++ src/ftp-basic.c | 14 ++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index f78b85e..d6a0ceb 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,11 @@ 2014-11-19 Tim Ruehsen + * ftp-basic.c (ftp_epsv): Fix loop check + + Reported-by: Coverity scanner + +2014-11-19 Tim Ruehsen + * openssl.c (ssl_check_certificate): Fix memory leak 2014-11-19 Tim Ruehsen diff --git a/src/ftp-basic.c b/src/ftp-basic.c index b6e67e2..83cc447 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 */ -- 2.1.3