test1599: verify a bad FTP password with no user

Verifies the fix from #17659

Closes #17687
This commit is contained in:
Daniel Stenberg 2025-06-20 22:13:42 +02:00
parent f9548bf20e
commit 149d436457
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
4 changed files with 95 additions and 5 deletions

View 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 \

45
tests/data/test1599 Normal file
View file

@ -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>

View 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 \
\

46
tests/libtest/lib1599.c Normal file
View file

@ -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;
}