]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
ftp: avoid SIZE when asking for a TYPE A file
authorDaniel Stenberg <daniel@haxx.se>
Thu, 4 Feb 2021 12:05:03 +0000 (13:05 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 4 Feb 2021 22:06:03 +0000 (23:06 +0100)
... as we ignore it anyway because servers don't report the correct size
and proftpd even blatantly returns a 550.

Updates a set of tests accordingly.

Reported-by: awesomenode on github
Fixes #6564
Closes #6565

lib/ftp.c
tests/data/Makefile.inc
tests/data/test105
tests/data/test106
tests/data/test129 [deleted file]
tests/data/test143
tests/data/test336
tests/data/test337
tests/data/test562

index cfccc390def4e5220152203daaa965bc8c7db46c..8de959c40a7638a53eb93d84a625e8eaf339086f 100644 (file)
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -1747,13 +1747,19 @@ static CURLcode ftp_state_quote(struct Curl_easy *data,
           result = ftp_state_retr(data, ftpc->known_filesize);
         }
         else {
-          if(data->set.ignorecl) {
-            /* This code is to support download of growing files.  It prevents
-               the state machine from requesting the file size from the
-               server.  With an unknown file size the download continues until
-               the server terminates it, otherwise the client stops if the
-               received byte count exceeds the reported file size.  Set option
-               CURLOPT_IGNORE_CONTENT_LENGTH to 1 to enable this behavior.*/
+          if(data->set.ignorecl || data->set.prefer_ascii) {
+            /* 'ignorecl' is used to support download of growing files.  It
+               prevents the state machine from requesting the file size from
+               the server.  With an unknown file size the download continues
+               until the server terminates it, otherwise the client stops if
+               the received byte count exceeds the reported file size.  Set
+               option CURLOPT_IGNORE_CONTENT_LENGTH to 1 to enable this
+               behavior.
+
+               In addition: asking for the size for 'TYPE A' transfers is not
+               constructive since servers don't report the converted size. So
+               skip it.
+            */
             result = Curl_pp_sendf(data, &ftpc->pp, "RETR %s", ftpc->file);
             if(!result)
               state(data, FTP_RETR);
index 5ebf049b8e95e9938ec98443140be144cfb43535..6b6f2bc5fdea0dfc75026e8be5704dc741e5eea8 100644 (file)
@@ -34,7 +34,7 @@ test90 test91 test92 test93 test94 test95 test96 test97 test98 test99   \
 test100 test101 test102 test103 test104 test105 test106 test107 test108 \
 test109 test110 test111 test112 test113 test114 test115 test116 test117 \
 test118 test119 test120 test121 test122 test123 test124 test125 test126 \
-test127 test128 test129 test130 test131 test132 test133 test134 test135 \
+test127 test128         test130 test131 test132 test133 test134 test135 \
 test136 test137 test138 test139 test140 test141 test142 test143 test144 \
 test145 test146 test147 test148 test149 test150 test151 test152 test153 \
 test154 test155 test156 test157 test158 test159 test160 test161 test162 \
index cc811aeb8360890e0b42b9a87b6102d984f296bc..14679d17ba3593b24c812056634e72c73e6379e7 100644 (file)
@@ -19,7 +19,6 @@ works
 </data>
 <servercmd>
 REPLY EPSV 500 no such command
-REPLY SIZE 500 no such command
 </servercmd>
 </reply>
 
@@ -45,7 +44,6 @@ PWD
 EPSV\r
 PASV\r
 TYPE A\r
-SIZE 105\r
 RETR 105\r
 QUIT\r
 </protocol>
index 56eca64205e4269a681aa7508acef25f21d49dd3..b7676f7a07bc1c2247f02f24845952734e664ddc 100644 (file)
@@ -44,7 +44,6 @@ CWD path with  spaces
 CWD and things2\r
 EPSV\r
 TYPE A\r
-SIZE 106\r
 RETR 106\r
 QUIT\r
 </protocol>
diff --git a/tests/data/test129 b/tests/data/test129
deleted file mode 100644 (file)
index cf1e839..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-<testcase>
-<info>
-<keywords>
-FTP
-EPSV
-TYPE A
-RETR
-type=
-</keywords>
-</info>
-# Server-side
-<reply>
-<size>
-37
-</size>
-<data>
-data
-    to
-      see
-that FTP
-works
-  so does it?
-</data>
-</reply>
-
-# Client-side
-<client>
-<server>
-ftp
-</server>
- <name>
-FTP GET with type=A style ASCII URL and understated server SIZE
- </name>
- <command>
-"ftp://%HOSTIP:%FTPPORT/129;type=A"
-</command>
-</client>
-
-# Verify data after the test has been "shot"
-<verify>
-<protocol>
-USER anonymous\r
-PASS ftp@example.com\r
-PWD\r
-EPSV\r
-TYPE A\r
-SIZE 129\r
-RETR 129\r
-QUIT\r
-</protocol>
-</verify>
-</testcase>
index 0f36dd9c37c5c5a41cc823673690cb1762bdaf42..22bec33237a534a38c33d6c745513778f821b997 100644 (file)
@@ -37,7 +37,6 @@ CWD tmp
 CWD moo\r
 EPSV\r
 TYPE A\r
-SIZE 143\r
 RETR 143\r
 QUIT\r
 </protocol>
index 85477c96cbaf0d6128112fcd908138e3fedb6817..cba846d4b3e7173a9335b070d850e27d1b964228 100644 (file)
@@ -35,7 +35,7 @@ ftp
 FTP range download when SIZE doesn't work
  </name>
  <command>
-ftp://%HOSTIP:%FTPPORT/336 --use-ascii --range 3-6
+ftp://%HOSTIP:%FTPPORT/336 --range 3-6
 </command>
 </client>
 
@@ -47,7 +47,7 @@ PASS ftp@example.com
 PWD\r
 EPSV\r
 PASV\r
-TYPE A\r
+TYPE I\r
 SIZE 336\r
 REST 3\r
 RETR 336\r
index 80086dda7c53b1e30e786b7c02c82972b69f96c0..9ae4dfac5e976c02692149ad6659fb8baec2ad49 100644 (file)
@@ -35,7 +35,7 @@ ftp
 FTP range download with SIZE returning extra crap
  </name>
  <command>
-ftp://%HOSTIP:%FTPPORT/337 --use-ascii --range 3-6
+ftp://%HOSTIP:%FTPPORT/337 --range 3-6
 </command>
 </client>
 
@@ -47,7 +47,7 @@ PASS ftp@example.com
 PWD\r
 EPSV\r
 PASV\r
-TYPE A\r
+TYPE I\r
 SIZE 337\r
 REST 3\r
 RETR 337\r
index 070cf7aa1c13977df064aec023fb69873da05ca4..35f4f53d7d9e1aeb936fba1cb6cba53d5998b534 100644 (file)
@@ -45,7 +45,6 @@ PASS ftp@example.com
 PWD\r
 EPSV\r
 TYPE A\r
-SIZE 562\r
 RETR 562\r
 QUIT\r
 </protocol>