From: hniksic Date: Wed, 15 Jun 2005 20:11:50 +0000 (-0700) Subject: [svn] Handle invalid response to PWD gracefully. X-Git-Tag: v1.13~998 X-Git-Url: http://sjero.net/git/?p=wget;a=commitdiff_plain;h=4f22c2f5679a823af9387cb724b28ecfefa53eee [svn] Handle invalid response to PWD gracefully. --- diff --git a/src/ChangeLog b/src/ChangeLog index bc9df474..aff94457 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2005-06-15 Hrvoje Niksic + + * ftp-basic.c (ftp_pwd): Handle malformed PWD response. + 2005-06-15 Hrvoje Niksic * host.h (ip_address): Remove the trailing comma from the type diff --git a/src/ftp-basic.c b/src/ftp-basic.c index 3c43b0c1..0dee6d09 100644 --- a/src/ftp-basic.c +++ b/src/ftp-basic.c @@ -1081,6 +1081,7 @@ ftp_pwd (int csock, char **pwd) return err; if (*respline == '5') { + err: xfree (respline); return FTPSRVERR; } @@ -1089,6 +1090,10 @@ ftp_pwd (int csock, char **pwd) and everything following it. */ strtok (respline, "\""); request = strtok (NULL, "\""); + if (!request) + /* Treat the malformed response as an error, which the caller has + to handle gracefully anyway. */ + goto err; /* Has the `pwd' been already allocated? Free! */ xfree_null (*pwd);