From: Bill Middlecamp Date: Tue, 9 Apr 2013 20:18:33 +0000 (+0200) Subject: FTP: handle "rubbish" in front of directory name in 257 responses X-Git-Tag: curl-7_30_0~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e0fb2d86c9f789131588a7cc93e9e881d601cecd;p=curl FTP: handle "rubbish" in front of directory name in 257 responses When doing PWD, there's a 257 response which apparently some servers prefix with a comment before the path instead of after it as is otherwise the norm. Failing to parse this, several otherwise legitimate use cases break. Bug: http://curl.haxx.se/mail/lib-2013-04/0113.html --- diff --git a/lib/ftp.c b/lib/ftp.c index ec586baa7..dce23de75 100644 --- a/lib/ftp.c +++ b/lib/ftp.c @@ -2871,13 +2871,19 @@ static CURLcode ftp_statemach_act(struct connectdata *conn) return CURLE_OUT_OF_MEMORY; /* Reply format is like - 257"" and the RFC959 - says + 257[rubbish]"" and the + RFC959 says The directory name can contain any character; embedded double-quotes should be escaped by double-quotes (the "quote-doubling" convention). */ + + /* scan for the first double-quote for non-standard responses */ + while(ptr < &data->state.buffer[sizeof(data->state.buffer)] + && *ptr != '\n' && *ptr != '\0' && *ptr != '"') + ptr++; + if('\"' == *ptr) { /* it started good */ ptr++;