cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: truncated files retrieved via FTP in ASCII mode

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Thu, 14 Jan 2010 23:28:42 +0100 (CET)

On Wed, 13 Jan 2010, David McCreedy wrote:

> The FTP server is returning the wrong SIZE for the file because it doesn't
> take the mode into account. (I think this is a common FTP server bug.)

Yeah, I think it is so common that FTP server authors probably don't even
consider it to be a bug.

> I can kludge the ftp_state_get_resp function in ftp.c to get back to the old
> behavior:

> + if((instate != FTP_LIST) && (data->set.prefer_ascii))
> + size = -1; /* kludge for servers that misstate file size in ASCII
> mode */

...

> But there must be a better way to deal with this...

libcurl has a very long-standing TODO about not properly supporting FTP ASCII
mode transfers (http://curl.haxx.se/docs/todo.html#ASCII_support) and this is
related to that.

I can only think of one better way to deal with this issue, and that is to
somehow count the number of CRLF occurances in the data and increase the
amount of expected downloaded bytes by that number. But that's kind of an
after-the-fact approach that doesn't quite help since we must first download
the proper amount of data before we can check for contents and count patterns
etc...

I think we should work on getting a test case like this added to the test
suite so that we can fix this in a way that won't get broken again in 6
months. Unfortunately I think it requires a modification of the test FTP
server.

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2010-01-14