summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2020-09-12 18:27:08 +0200
committerDaniel Stenberg <daniel@haxx.se>2020-09-12 18:27:08 +0200
commit3cda822a745ff0c3bd8c0f83f20eb3f1f4df4938 (patch)
tree4296808d5862b1e2ed17fb13dbf75bfda926f59f
parent5fbc3ee5200373820e14082fa7e96372506986bf (diff)
downloadcurl-bagder/ftp-size-550.tar.gz
ftp: a 550 response to SIZE is now an errorbagder/ftp-size-550
and returns CURLE_FTP_COULDNT_RETR_FILE. This is primarily interesting for cases where CURLOPT_NOBODY is set as otherwise curl would not return an error for this case. This is how libcurl already acts on a 550 as a MDTM response (when CURLOPT_FILETIME is set). If CURLOPT_NOBODY is not set, the error will happen subsequently anyway since the RETR command will also fail with it. Reported-by: Tomas Berger Fixes #5953
-rw-r--r--lib/ftp.c4
-rw-r--r--tests/data/Makefile.inc2
-rw-r--r--tests/data/test191341
-rw-r--r--tests/data/test191442
-rw-r--r--tests/libtest/Makefile.inc6
-rw-r--r--tests/libtest/lib1913.c48
6 files changed, 141 insertions, 2 deletions
diff --git a/lib/ftp.c b/lib/ftp.c
index 9fadac513..fbd65cc9d 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -2272,6 +2272,10 @@ static CURLcode ftp_state_size_resp(struct connectdata *conn,
(void)curlx_strtoofft(fdigit, NULL, 0, &filesize);
}
+ else if(ftpcode == 550) { /* "No such file or directory" */
+ failf(data, "The file does not exist");
+ return CURLE_FTP_COULDNT_RETR_FILE;
+ }
if(instate == FTP_SIZE) {
#ifdef CURL_FTP_HTTPSTYLE_HEAD
diff --git a/tests/data/Makefile.inc b/tests/data/Makefile.inc
index 435964e4e..f20967474 100644
--- a/tests/data/Makefile.inc
+++ b/tests/data/Makefile.inc
@@ -207,7 +207,7 @@ test1700 test1701 test1702 \
test1800 test1801 \
\
test1904 test1905 test1906 test1907 \
-test1908 test1909 test1910 test1911 test1912 \
+test1908 test1909 test1910 test1911 test1912 test1913 test1914 \
\
test2000 test2001 test2002 test2003 test2004 test2005 test2006 test2007 \
test2008 test2009 test2010 test2011 test2012 test2013 test2014 test2015 \
diff --git a/tests/data/test1913 b/tests/data/test1913
new file mode 100644
index 000000000..c66a7499e
--- /dev/null
+++ b/tests/data/test1913
@@ -0,0 +1,41 @@
+<testcase>
+<info>
+<keywords>
+FTP
+CURLOPT_NOBODY
+</keywords>
+</info>
+
+# Server-side
+<reply>
+<servercmd>
+REPLY SIZE 550 no such file
+</servercmd>
+</reply>
+
+# Client-side
+<client>
+<server>
+ftp
+</server>
+
+# require debug so that alt-svc can work over plain old HTTP
+<name>
+FTP with NOBODY set, getting a missing file
+</name>
+<tool>
+lib1913
+</tool>
+
+<command>
+ftp://%HOSTIP:%FTPPORT/not-there/1913
+</command>
+</client>
+
+# Verify data after the test has been "shot"
+<verify>
+<errorcode>
+19
+</errorcode>
+</verify>
+</testcase>
diff --git a/tests/data/test1914 b/tests/data/test1914
new file mode 100644
index 000000000..ce28ff63a
--- /dev/null
+++ b/tests/data/test1914
@@ -0,0 +1,42 @@
+<testcase>
+<info>
+<keywords>
+FTP
+CURLOPT_NOBODY
+CURLOPT_FILETIME
+</keywords>
+</info>
+
+# Server-side
+<reply>
+<servercmd>
+REPLY MDTM 550 no such file
+</servercmd>
+</reply>
+
+# Client-side
+<client>
+<server>
+ftp
+</server>
+
+# require debug so that alt-svc can work over plain old HTTP
+<name>
+FTP with NOBODY and FILETIME set, getting a missing file
+</name>
+<tool>
+lib1913
+</tool>
+
+<command>
+ftp://%HOSTIP:%FTPPORT/not-there/1913 1
+</command>
+</client>
+
+# Verify data after the test has been "shot"
+<verify>
+<errorcode>
+19
+</errorcode>
+</verify>
+</testcase>
diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc
index 88dd68529..9f570f8b8 100644
--- a/tests/libtest/Makefile.inc
+++ b/tests/libtest/Makefile.inc
@@ -58,7 +58,7 @@ noinst_PROGRAMS = chkhostname libauthretry libntlmconnect \
lib1550 lib1551 lib1552 lib1553 lib1554 lib1555 lib1556 lib1557 \
lib1558 lib1559 lib1560 lib1564 lib1565 lib1567 \
lib1591 lib1592 lib1593 lib1594 lib1596 \
- lib1905 lib1906 lib1907 lib1908 lib1910 lib1911 lib1912 \
+ lib1905 lib1906 lib1907 lib1908 lib1910 lib1911 lib1912 lib1913 \
lib3010
chkdecimalpoint_SOURCES = chkdecimalpoint.c ../../lib/mprintf.c \
@@ -645,6 +645,10 @@ lib1912_SOURCES = lib1912.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1912_LDADD = $(TESTUTIL_LIBS)
lib1912_CPPFLAGS = $(AM_CPPFLAGS)
+lib1913_SOURCES = lib1913.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
+lib1913_LDADD = $(TESTUTIL_LIBS)
+lib1913_CPPFLAGS = $(AM_CPPFLAGS)
+
lib3010_SOURCES = lib3010.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib3010_LDADD = $(TESTUTIL_LIBS)
lib3010_CPPFLAGS = $(AM_CPPFLAGS)
diff --git a/tests/libtest/lib1913.c b/tests/libtest/lib1913.c
new file mode 100644
index 000000000..b8ef96e36
--- /dev/null
+++ b/tests/libtest/lib1913.c
@@ -0,0 +1,48 @@
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+#include "test.h"
+
+#include "testutil.h"
+#include "warnless.h"
+#include "memdebug.h"
+
+int test(char *URL)
+{
+ CURLcode ret = CURLE_OK;
+ CURL *hnd;
+ start_test_timing();
+
+ curl_global_init(CURL_GLOBAL_ALL);
+
+ hnd = curl_easy_init();
+ if(hnd) {
+ curl_easy_setopt(hnd, CURLOPT_URL, URL);
+ curl_easy_setopt(hnd, CURLOPT_NOBODY, 1L);
+ if(libtest_arg2)
+ /* test1914 sets this extra arg */
+ curl_easy_setopt(hnd, CURLOPT_FILETIME, 1L);
+ ret = curl_easy_perform(hnd);
+ curl_easy_cleanup(hnd);
+ }
+ curl_global_cleanup();
+ return (int)ret;
+}