Skip to content

Infinite loop on CURLOPT_COOKIEFILE="/" #20823

Closed

Description

@rtollert

I did this

Our code is calling curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "/") instead of "" for hysterical raisins. While obviously problematic, I am not certain that it is forbidden? CURLOPT_COOKIEFILE(3) states that specifying a non-existent file, while not a good idea, should work identically to "". And, well, one could argue that the “file” / does not, strictly speaking, exist. (I admit this may be a bit of a stretch.)

Anyways, when we upgraded from 8.14 to 8.18 our code started hanging. Root cause appears to be curl_get_line: enhance the API. The crux is that fopen() on a directory works, even though fgets() will always fail — yet feof() always returns 0. (At least on my Linux box.)

I expected the following

It definitely shouldn't hang. I would prefer that setting a CURLOPT_COOKIEFILE="/" be treated equivalent to "", but in light of the whole purpose of 769ccb4 being to tighten up error handling, I could be persuaded that perhaps an error should now be returned. (EDIT: we've all agreed that the correct behavior is for directories to error out.)

curl/libcurl version

Regression observed in curl 8.18.0 versus 8.14.1

operating system

Observed both on Arch Linux and on a Yocto variant.

Activity

  1. added a commit that references this issue on Mar 5, 2026
    e0a023f
  2. self-assigned this
    on Mar 5, 2026
  3. added 2 commits that reference this issue on Mar 7, 2026
    198ab97
    b65da51
  4. added a commit that references this issue on Mar 16, 2026
    e76968e
  5. added a commit that references this issue on Jun 3, 2026
    b2e76e8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions