mirror of
https://github.com/moparisthebest/curl
synced 2025-01-11 05:58:01 -05:00
netrc: skip 'macdef' definitions
Add test 494 to verify Reported-by: Harry Sintonen Fixes #7238 Closes #7244
This commit is contained in:
parent
77bc35901f
commit
bbbc5de93f
25
lib/netrc.c
25
lib/netrc.c
@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2021, 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
|
||||
@ -42,7 +42,8 @@
|
||||
enum host_lookup_state {
|
||||
NOTHING,
|
||||
HOSTFOUND, /* the 'machine' keyword was found */
|
||||
HOSTVALID /* this is "our" machine! */
|
||||
HOSTVALID, /* this is "our" machine! */
|
||||
MACDEF
|
||||
};
|
||||
|
||||
#define NETRC_FILE_MISSING 1
|
||||
@ -84,12 +85,17 @@ static int parsenetrc(const char *host,
|
||||
int netrcbuffsize = (int)sizeof(netrcbuffer);
|
||||
|
||||
while(!done && fgets(netrcbuffer, netrcbuffsize, file)) {
|
||||
if(state == MACDEF) {
|
||||
if((netrcbuffer[0] == '\n') || (netrcbuffer[0] == '\r'))
|
||||
state = NOTHING;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
tok = strtok_r(netrcbuffer, " \t\n", &tok_buf);
|
||||
if(tok && *tok == '#')
|
||||
/* treat an initial hash as a comment line */
|
||||
continue;
|
||||
while(tok) {
|
||||
|
||||
if((login && *login) && (password && *password)) {
|
||||
done = TRUE;
|
||||
break;
|
||||
@ -97,7 +103,13 @@ static int parsenetrc(const char *host,
|
||||
|
||||
switch(state) {
|
||||
case NOTHING:
|
||||
if(strcasecompare("machine", tok)) {
|
||||
if(strcasecompare("macdef", tok)) {
|
||||
/* Define a macro. A macro is defined with the specified name; its
|
||||
contents begin with the next .netrc line and continue until a
|
||||
null line (consecutive new-line characters) is encountered. */
|
||||
state = MACDEF;
|
||||
}
|
||||
else if(strcasecompare("machine", tok)) {
|
||||
/* the next tok is the machine name, this is in itself the
|
||||
delimiter that starts the stuff entered for this machine,
|
||||
after this we need to search for 'login' and
|
||||
@ -109,6 +121,11 @@ static int parsenetrc(const char *host,
|
||||
retcode = NETRC_SUCCESS; /* we did find our host */
|
||||
}
|
||||
break;
|
||||
case MACDEF:
|
||||
if(!strlen(tok)) {
|
||||
state = NOTHING;
|
||||
}
|
||||
break;
|
||||
case HOSTFOUND:
|
||||
if(strcasecompare(host, tok)) {
|
||||
/* and yes, this is our host! */
|
||||
|
@ -69,7 +69,7 @@ test409 test410 \
|
||||
\
|
||||
test430 test431 test432 test433 test434 \
|
||||
\
|
||||
test490 test491 test492 test493 \
|
||||
test490 test491 test492 test493 test494 \
|
||||
\
|
||||
test500 test501 test502 test503 test504 test505 test506 test507 test508 \
|
||||
test509 test510 test511 test512 test513 test514 test515 test516 test517 \
|
||||
|
60
tests/data/test494
Normal file
60
tests/data/test494
Normal file
@ -0,0 +1,60 @@
|
||||
<testcase>
|
||||
<info>
|
||||
<keywords>
|
||||
FTP
|
||||
EPSV
|
||||
netrc
|
||||
macdef
|
||||
</keywords>
|
||||
</info>
|
||||
#
|
||||
# Server-side
|
||||
<reply>
|
||||
<data>
|
||||
blipp
|
||||
</data>
|
||||
</reply>
|
||||
|
||||
#
|
||||
# Client-side
|
||||
<client>
|
||||
<server>
|
||||
ftp
|
||||
</server>
|
||||
<name>
|
||||
skip 'macdef' when parsing netrc
|
||||
</name>
|
||||
<command>
|
||||
--netrc --netrc-file log/netrc%TESTNUMBER ftp://%HOSTIP:%FTPPORT/%TESTNUMBER
|
||||
</command>
|
||||
<file name="log/netrc%TESTNUMBER" >
|
||||
|
||||
macdef testmacro
|
||||
bin
|
||||
cd default
|
||||
cd login
|
||||
put login.bin
|
||||
cd ..
|
||||
cd password
|
||||
put password.bin
|
||||
quit
|
||||
|
||||
machine %HOSTIP login user1 password passwd1
|
||||
</file>
|
||||
</client>
|
||||
|
||||
#
|
||||
# Verify data after the test has been "shot"
|
||||
<verify>
|
||||
<protocol>
|
||||
USER user1
|
||||
PASS passwd1
|
||||
PWD
|
||||
EPSV
|
||||
TYPE I
|
||||
SIZE %TESTNUMBER
|
||||
RETR %TESTNUMBER
|
||||
QUIT
|
||||
</protocol>
|
||||
</verify>
|
||||
</testcase>
|
Loading…
Reference in New Issue
Block a user