Skip to content

cookie: reload complete self-generated cookie jar rows - #23407

Closed
cla7aye15I4nd wants to merge 4 commits into
curl:masterfrom
cla7aye15I4nd:zheng/curl-cookie-jar-roundtrip
Closed

cla7aye15I4nd wants to merge 4 commits into
curl:masterfrom
cla7aye15I4nd:zheng/curl-cookie-jar-roundtrip

Conversation

@cla7aye15I4nd

@cla7aye15I4nd cla7aye15I4nd commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

curl -c saves accepted cookies through cookie_output() in lib/cookie.c. It writes each Netscape cookie-jar row with the cookie's domain and path, so a row can exceed cookie_load()'s 5,048-byte line limit even when the cookie itself was accepted. A later curl -b then fails with CURLE_TOO_LARGE before sending a request.

Raise the loader's line limit to DYN_APRINTF + 2. get_netscape_format() uses curl_maprintf(), which can return at most DYN_APRINTF - 1 bytes; the writer adds up to two newline bytes on Windows, and the reader needs one byte for its terminating NUL. This lets curl reload any jar row it successfully wrote. The limit is a growth cap, not an up-front allocation.

Unit 3424 covers long domain/path rows and an ordinary cookie surviving a save-and-reload round trip. A local curl -c / curl -b reproduction fails before this change and succeeds with it; the unit test and checksrc pass.

@github-actions github-actions Bot added the tests label Oct 15, 2026
Comment thread lib/cookie.c Resolved
Comment thread tests/unit/unit3424.c Resolved
@cla7aye15I4nd
cla7aye15I4nd marked this pull request as ready for review October 15, 2026 07:32
@cla7aye15I4nd cla7aye15I4nd changed the title [DONE] cookie: reload complete self-generated cookie jar rows cookie: reload complete self-generated cookie jar rows Oct 15, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The bounded change matches the writer’s capacity and includes regression coverage, with no unresolved findings.

0 open findings

What changed in this PR

Allows curl to reload long cookie-jar rows that its own writer can produce.

Changes:

  • Raises the loader’s line cap to DYN_APRINTF + 2, accounting for newline and terminator bytes.
  • Extends test 1902 to verify long and ordinary cookies reload without a transfer.
File Description
tests/​libtest/​lib1902.c Checks explicit reload and both cookies’ presence.
tests/​data/​test1902 Adds a long-path cookie fixture and expected output.
lib/​cookie.c Aligns the loader cap with the writer’s maximum output.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@bagder bagder closed this in 7d64440 Oct 15, 2026
@bagder

bagder commented Oct 15, 2026

Copy link
Copy Markdown
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

4 participants