]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
test1599: verify a bad FTP password with no user
authorDaniel Stenberg <daniel@haxx.se>
Fri, 20 Jun 2025 20:13:42 +0000 (22:13 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 20 Jun 2025 21:14:14 +0000 (23:14 +0200)
Verifies the fix from #17659

Closes #17687

tests/data/Makefile.am
tests/data/test1599 [new file with mode: 0644]
tests/libtest/Makefile.inc
tests/libtest/lib1599.c [new file with mode: 0644]

index 8fc0b3480a83c8e42514d71fdf96ec37cd8a1c27..7b519da8ae0464b639b16f641aee29c190d9bf78 100644 (file)
@@ -211,10 +211,9 @@ test1566 test1567 test1568 test1569 test1570 test1571 test1572 test1573 \
 test1574 test1575 test1576 test1577 test1578 test1579 test1580 test1581 \
 \
 test1590 test1591 test1592 test1593 test1594 test1595 test1596 test1597 \
-test1598 \
-test1600 test1601 test1602 test1603 test1604 test1605 test1606 test1607 \
-test1608 test1609 test1610 test1611 test1612 test1613 test1614 test1615 \
-test1616 \
+test1598 test1599 test1600 test1601 test1602 test1603 test1604 test1605 \
+test1606 test1607 test1608 test1609 test1610 test1611 test1612 test1613 \
+test1614 test1615 test1616 \
 test1620 test1621 \
 \
 test1630 test1631 test1632 test1633 test1634 test1635 \
diff --git a/tests/data/test1599 b/tests/data/test1599
new file mode 100644 (file)
index 0000000..60d5338
--- /dev/null
@@ -0,0 +1,45 @@
+<testcase>
+<info>
+<keywords>
+FTP
+netrc
+</keywords>
+</info>
+
+# Test based on GitHub issue 17659
+#
+# Server-side
+<reply>
+<data>
+-foo-
+</data>
+</reply>
+
+#
+# Client-side
+<client>
+<server>
+ftp
+</server>
+<name>
+FTP with netrc using no user but control code in password
+</name>
+<command>
+ftp://%HOSTIP:%FTPPORT/%TESTNUMBER log/netrc%TESTNUMBER
+</command>
+<tool>
+lib%TESTNUMBER
+</tool>
+<file name="log/netrc%TESTNUMBER" nonewline="yes">
+default   passwor?dlogin anonymou\ ' password login anonymous       passwor?d.'macdef
+</file>
+</client>
+
+#
+# Verify data after the test has been "shot"
+<verify>
+<errorcode>
+0
+</errorcode>
+</verify>
+</testcase>
index 77c7cbdc27a798fb2035ea2a811de03c0ee15e48..4619f70ff69e7b2be57d6d7fea1a1e7ccd9a152c 100644 (file)
@@ -68,7 +68,7 @@ TESTFILES = \
   lib1550.c lib1551.c lib1552.c lib1553.c lib1554.c lib1555.c lib1556.c lib1557.c \
   lib1558.c lib1559.c lib1560.c lib1564.c lib1565.c lib1567.c lib1568.c lib1569.c lib1571.c \
                                 lib1576.c \
-  lib1591.c lib1592.c lib1593.c lib1594.c           lib1597.c lib1598.c \
+  lib1591.c lib1592.c lib1593.c lib1594.c           lib1597.c lib1598.c lib1599.c \
   \
   lib1662.c \
   \
diff --git a/tests/libtest/lib1599.c b/tests/libtest/lib1599.c
new file mode 100644 (file)
index 0000000..30f2033
--- /dev/null
@@ -0,0 +1,46 @@
+/***************************************************************************
+ *                                  _   _ ____  _
+ *  Project                     ___| | | |  _ \| |
+ *                             / __| | | | |_) | |
+ *                            | (__| |_| |  _ <| |___
+ *                             \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 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.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.
+ *
+ * SPDX-License-Identifier: curl
+ *
+ ***************************************************************************/
+#include "test.h"
+
+#include "testtrace.h"
+
+static CURLcode test_lib1599(char *URL)
+{
+  CURL *curl;
+  CURLcode res = CURLE_OK;
+
+  global_init(CURL_GLOBAL_ALL);
+  curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, URL);
+    curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
+    curl_easy_setopt(curl, CURLOPT_NETRC, (long)CURL_NETRC_REQUIRED);
+    curl_easy_setopt(curl, CURLOPT_NETRC_FILE, libtest_arg2);
+
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
+  curl_global_cleanup();
+  return res;
+}