Commit 02892e4f authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

FTP quote commands prefixed with '*' now can fail without aborting

Prefixing the FTP quote commands with an asterisk really only
worked for the postquote actions. This is now fixed and test case
227 has been extended to verify.
parent 10977f57
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -6,6 +6,11 @@


                                  Changelog
                                  Changelog


Daniel Stenberg (9 Apr 2010)
- Prefixing the FTP quote commands with an asterisk really only worked for the
  postquote actions. This is now fixed and test case 227 has been extended to
  verify.

Kamil Dudka (4 Apr 2010)
Kamil Dudka (4 Apr 2010)
- Eliminated a race condition in Curl_resolv_timeout().
- Eliminated a race condition in Curl_resolv_timeout().


+1 −0
Original line number Original line Diff line number Diff line
@@ -45,6 +45,7 @@ This release includes the following bugfixes:
 o RTSP GET_PARAMETER
 o RTSP GET_PARAMETER
 o timeout after last data chunk was handled
 o timeout after last data chunk was handled
 o SFTP download hang
 o SFTP download hang
 o FTP quote commands prefixed with '*' now can fail without aborting


This release includes the following known bugs:
This release includes the following known bugs:


+17 −2
Original line number Original line Diff line number Diff line
@@ -1424,6 +1424,12 @@ static CURLcode ftp_state_quote(struct connectdata *conn,
    break;
    break;
  }
  }


  /*
   * This state uses:
   * 'count1' to iterate over the commands to send
   * 'count2' to store wether to allow commands to fail
   */

  if(init)
  if(init)
    ftpc->count1 = 0;
    ftpc->count1 = 0;
  else
  else
@@ -1438,7 +1444,15 @@ static CURLcode ftp_state_quote(struct connectdata *conn,
      i++;
      i++;
    }
    }
    if(item) {
    if(item) {
      PPSENDF(&ftpc->pp, "%s", item->data);
      char *cmd = item->data;
      if(cmd[0] == '*') {
        cmd++;
        ftpc->count2 = 1; /* the sent command is allowed to fail */
      }
      else
        ftpc->count2 = 0; /* failure means cancel operation */

      PPSENDF(&ftpc->pp, "%s", cmd);
      state(conn, instate);
      state(conn, instate);
      quote = TRUE;
      quote = TRUE;
    }
    }
@@ -2658,7 +2672,8 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
    case FTP_POSTQUOTE:
    case FTP_POSTQUOTE:
    case FTP_RETR_PREQUOTE:
    case FTP_RETR_PREQUOTE:
    case FTP_STOR_PREQUOTE:
    case FTP_STOR_PREQUOTE:
      if(ftpcode >= 400) {
      if((ftpcode >= 400) && !ftpc->count2) {
        /* failure reponse code, and not allowed to fail */
        failf(conn->data, "QUOT command failed with %03d", ftpcode);
        failf(conn->data, "QUOT command failed with %03d", ftpcode);
        return CURLE_QUOTE_ERROR;
        return CURLE_QUOTE_ERROR;
      }
      }
+4 −1
Original line number Original line Diff line number Diff line
@@ -19,6 +19,7 @@ works
</data>
</data>
<servercmd>
<servercmd>
REPLY EPSV 500 no such command
REPLY EPSV 500 no such command
REPLY FAIL 500 this might not be a failure!
</servercmd>
</servercmd>
</reply>
</reply>


@@ -31,7 +32,7 @@ ftp
FTP with quote ops
FTP with quote ops
 </name>
 </name>
 <command>
 <command>
ftp://%HOSTIP:%FTPPORT/227 -Q "NOOP 1" -Q "+NOOP 2" -Q "-NOOP 3"
ftp://%HOSTIP:%FTPPORT/227 -Q "NOOP 1" -Q "+NOOP 2" -Q "-NOOP 3" -Q "*FAIL" -Q "+*FAIL HARD"
</command>
</command>
</client>
</client>


@@ -42,10 +43,12 @@ USER anonymous
PASS ftp@example.com
PASS ftp@example.com
PWD
PWD
NOOP 1
NOOP 1
FAIL
EPSV
EPSV
PASV
PASV
TYPE I
TYPE I
NOOP 2
NOOP 2
FAIL HARD
SIZE 227
SIZE 227
RETR 227
RETR 227
NOOP 3
NOOP 3