Nagy Ferenc László <[EMAIL PROTECTED]> writes:
> If the ftp server returns invalid data (for example '221 Bye.') in
> response to PWD, wget segfaults because in ftp_pwd (ftp-basic.c)
> request will be NULL after the line 'request = strtok (NULL,
> "\"");', and this NULL will be passed to xstrdup.
Thanks for the report; this patch should fix the problem:
2005-06-15 Hrvoje Niksic <[EMAIL PROTECTED]>
* ftp-basic.c (ftp_pwd): Handle malformed PWD response.
Index: src/ftp-basic.c
===================================================================
RCS file: /pack/anoncvs/wget/src/ftp-basic.c,v
retrieving revision 1.47
diff -u -r1.47 ftp-basic.c
--- src/ftp-basic.c 2005/05/16 22:08:57 1.47
+++ src/ftp-basic.c 2005/06/15 20:10:43
@@ -1081,6 +1081,7 @@
return err;
if (*respline == '5')
{
+ err:
xfree (respline);
return FTPSRVERR;
}
@@ -1089,6 +1090,10 @@
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);