From 4f22c2f5679a823af9387cb724b28ecfefa53eee Mon Sep 17 00:00:00 2001 From: hniksic Date: Wed, 15 Jun 2005 13:11:50 -0700 Subject: [PATCH] [svn] Handle invalid response to PWD gracefully. --- src/ChangeLog | 4 ++++ src/ftp-basic.c | 5 +++++ 2 files changed, 9 insertions(+) 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);