duphandle: also init netrc

The netrc init was only done in the Curl_open, meaning that a duplicated
handle would not get inited properly.

Added test 2309 to verify. It does netrc auth with a duplicated handle.

Regression from 3b43a05e00

Reported-by: tranzystorekk on github
Fixes #15496
Closes #15503
This commit is contained in:
Daniel Stenberg 2024-11-07 08:52:38 +01:00
parent 9919149aef
commit f5c616930b
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
5 changed files with 138 additions and 2 deletions

View file

@ -255,7 +255,7 @@ test2100 \
test2200 test2201 test2202 test2203 test2204 test2205 \
\
test2300 test2301 test2302 test2303 test2304 test2305 test2306 test2307 \
test2308 \
test2308 test2309 \
\
test2400 test2401 test2402 test2403 test2404 test2405 test2406 \
\

66
tests/data/test2309 Normal file
View file

@ -0,0 +1,66 @@
<testcase>
<info>
<keywords>
netrc
HTTP
</keywords>
</info>
#
# Server-side
<reply>
<data crlf="yes" nocheck="yes">
HTTP/1.1 200 OK
Date: Tue, 09 Nov 2010 14:49:00 GMT
Server: test-server/fake
Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
ETag: "21025-dc7-39462498"
Accept-Ranges: bytes
Content-Length: 6
Connection: close
Content-Type: text/html
Funny-head: yesyes
-foo-
</data>
</reply>
#
# Client-side
<client>
<server>
http
</server>
<features>
proxy
</features>
# Reproducing issue 15496
<name>
HTTP with .netrc using duped easy handle
</name>
<tool>
lib%TESTNUMBER
</tool>
<command>
http://github.com %LOGDIR/netrc%TESTNUMBER http://%HOSTIP:%HTTPPORT/
</command>
<file name="%LOGDIR/netrc%TESTNUMBER" >
machine github.com
login daniel
password $y$j9T$WUVjiVvDbRAWafDLs6cab1$01NX.oaZKf5lw8MR2Nk9Yaxv4CqbE0IaDF.GpGxPul1
</file>
</client>
<verify>
<protocol>
GET http://github.com/ HTTP/1.1
Host: github.com
Authorization: Basic %b64[daniel:$y$j9T$WUVjiVvDbRAWafDLs6cab1$01NX.oaZKf5lw8MR2Nk9Yaxv4CqbE0IaDF.GpGxPul1]b64%
Accept: */*
Proxy-Connection: Keep-Alive
</protocol>
</verify>
</testcase>