From 149d436457ba87ac5f19c3b9dfbfd6d1b5733d76 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 20 Jun 2025 22:13:42 +0200 Subject: [PATCH] test1599: verify a bad FTP password with no user Verifies the fix from #17659 Closes #17687 --- tests/data/Makefile.am | 7 +++--- tests/data/test1599 | 45 +++++++++++++++++++++++++++++++++++++ tests/libtest/Makefile.inc | 2 +- tests/libtest/lib1599.c | 46 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 95 insertions(+), 5 deletions(-) create mode 100644 tests/data/test1599 create mode 100644 tests/libtest/lib1599.c diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index 8fc0b3480a..7b519da8ae 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -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 index 0000000000..60d5338f63 --- /dev/null +++ b/tests/data/test1599 @@ -0,0 +1,45 @@ + + + +FTP +netrc + + + +# Test based on GitHub issue 17659 +# +# Server-side + + +-foo- + + + +# +# Client-side + + +ftp + + +FTP with netrc using no user but control code in password + + +ftp://%HOSTIP:%FTPPORT/%TESTNUMBER log/netrc%TESTNUMBER + + +lib%TESTNUMBER + + +default passwor?dlogin anonymou\ ' password login anonymous passwor?d.'macdef + + + +# +# Verify data after the test has been "shot" + + +0 + + + diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index 77c7cbdc27..4619f70ff6 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -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 index 0000000000..30f2033226 --- /dev/null +++ b/tests/libtest/lib1599.c @@ -0,0 +1,46 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) Daniel Stenberg, , 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; +} -- 2.47.2