curl-curl/tests/data/test1713
Viktor Szakats e76968e20d
curl_get_line: fix potential infinite loop when filename is a directory
Fix potential inifinite loop reading file content with `Curl_get_line()`
when a filename passed via these options are pointing to a directory
entry (on non-Windows):

- `--alt-svc` / `CURLOPT_ALTSVC`
- `-b` / `--cookie` / `CURLOPT_COOKIEFILE`
- `--hsts` / `CURLOPT_HSTS`
- `--netrc-file` / `CURLOPT_NETRC_FILE`

Fix by checking for this condition and silently skipping such filename
without attempting to read content. Add test 1713 to verify.

Mention in cookie documentation as an accepted case, also show a verbose
message when a directory is detected. Extend test 46 to verify if such
failure lets the logic continue to the next cookie file.

Reported-and-based-on-patch-by: Richard Tollerton
Fixes #20823
Closes #20826 (originally-based-on)
Follow-up to 769ccb4d42 #19140

Closes #20873
2026-03-16 11:54:43 +01:00

37 lines
493 B
XML

<?xml version="1.0" encoding="US-ASCII"?>
<testcase>
<info>
<keywords>
HTTP
HTTP GET
Alt-Svc
cookies
HSTS
netrc
</keywords>
</info>
# Client-side
<client>
<name>
Filenames pointing to directory failing gracefully
</name>
<command>
http://invalid.invalid/%TESTNUMBER --alt-svc %LOGDIR --cookie %LOGDIR --hsts %LOGDIR --netrc-file %LOGDIR
</command>
<features>
alt-svc
cookies
HSTS
netrc
</features>
</client>
<verify>
# 26 = CURLE_READ_ERROR
<errorcode>
26
</errorcode>
</verify>
</testcase>