Skip to content

tool: reject more than 2 GB of data to URL encode - #23547

Closed
Marti2203 wants to merge 1 commit into
curl:masterfrom
Marti2203:data-urlencode-large
Closed

Marti2203 wants to merge 1 commit into
curl:masterfrom
Marti2203:data-urlencode-large

Conversation

@Marti2203

Copy link
Copy Markdown
Contributor

Since ad6320b (8.10.0) curl can load up to 16 GB of a file into memory on 64-bit systems, but --data-urlencode and the :url variable function still pass the size to curl_easy_escape() cast to int.

With a file of 4 GB plus 11 bytes, curl silently sends only the first 11 bytes, encoded, and exits 0:

$ curl --data-urlencode @big http://localhost:8000/

the server gets 33 bytes (%00 x 11). With name@big it gets name= plus the same 33 bytes, and --variable v@big --expand-data '{{v:url}}' does the same. Between 2 and 4 GB, curl says "out of memory".

This refuses such data with an error instead. I did not add a test since it needs a file of more than 2 GB.

Since the in-memory size limit was raised to 16 GB on 64-bit systems in
ad6320b, file2memory() can return more than INT_MAX bytes, but
--data-urlencode and the :url variable function pass the size to
curl_easy_escape() cast to int. With a file of 4 GB plus 11 bytes, curl
silently sent only the first 11 bytes encoded. Between 2 and 4 GB, it
said "out of memory".

Refuse such data with an error instead.
@dfandrich

dfandrich commented Oct 22, 2026 via email

Copy link
Copy Markdown
Contributor

@Marti2203

Copy link
Copy Markdown
Contributor Author

Thanks. Besides the sparse file, curl reads the data into memory (file2memory), so a test would also need more than 2 GB of RAM in every CI job that runs it. That seemed too heavy for a one-line cast fix, so I left it without a test, but I can add one if you think it's worth it.

@dfandrich

dfandrich commented Oct 22, 2026 via email

Copy link
Copy Markdown
Contributor

@bagder bagder closed this in c6d66ab Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants