cURL / Mailing Lists / curl-library / Single Mail

curl-library

Recognizing a non-standard FTP response to PWD & MKD commands

From: Bill Middlecamp <Bill.Middlecamp_at_quantum.com>
Date: Tue, 9 Apr 2013 14:35:42 +0000

I would like to request that a change be added to libcURL so that it will accept a slightly non-compliant FTPD 257 response.

I have written an FTP client to interface with a customized FTP daemon in a storage appliance for the video industry. The vendor of this appliance implemented a non-RFC 959 response 257 to the PWD and MKD commands. The standard specifies the response to PWD and MKD commands be of the following form:

  257<space>"<directory-name>"<space><commentary>

The vendor incorrectly implemented the response in the following form:

  257<space><space><commentary>"<directory-name>"

I could not require that the FTP daemon be fixed and deployed, so I made a simple change to libcURL to accept the non-standard response. Without this change, libcurl can lose track of the HOME directory under the following scenario:

1) Set CURLOPT_FTP_FILEMETHOD to MULTICWD, and upload a temporary file to get libcurl to create the missing elements of a directory path as needed, then DELE the temporary file with a POSTQUOTE command.

2) Set CURLOPT_FTP_FILEMETHOD to NOCWD to support QUOTE commands with pathnames rooted in the user's HOME directory.

I realize that this is an unusual way to use CURLOPT_FTP_FILEMETHOD, but it works with RFC 959 compliant FTP servers. Using MULTICWD allows for efficient directory-path creation, but it is very difficult to use QUOTE commands with MULTICWD since it is difficult to know either the absolute path name or the current directory for a relative path name.

Following is the patch that allows the non-compliant 257 response to be parsed:

--- curl-7.29.0_new/lib/ftp.c 2013-03-25 09:33:57.984270281 -0500
+++ curl-7.29.0/lib/ftp.c 2013-01-17 15:40:43.000000000 -0600
@@ -2873,15 +2873,6 @@
            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 != '\0'
- && *ptr != '"'
- ) {
- ptr++;
- }
-
         if('\"' == *ptr) {
           /* it started good */
           ptr++;

----------------------------------------------------------------------
The information contained in this transmission may be confidential. Any disclosure, copying, or further distribution of confidential information is not permitted unless such privilege is explicitly granted in writing by Quantum. Quantum reserves the right to have electronic communications, including email and attachments, sent across its networks filtered through anti virus and spam software programs and retain such messages in order to comply with applicable data security and retention requirements. Quantum is not responsible for the proper and complete transmission of the substance of this communication or for any delay in its receipt.

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2013-04-09