Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

curl -G --data x / returns curl: (27) Out of memory #9889

Closed
Hello71 opened this issue Nov 11, 2022 · 6 comments
Closed

curl -G --data x / returns curl: (27) Out of memory #9889

Hello71 opened this issue Nov 11, 2022 · 6 comments
Assignees

Comments

@Hello71
Copy link
Contributor

Hello71 commented Nov 11, 2022

Steps to reproduce

curl -G --data x /

Expected results

No output, or curl: (3) URL using bad/illegal format or missing URL.

Actual results

curl: (27) Out of memory

Additional information

The actual command is closer to curl -Gso /dev/null -w '%{url_effective}' --data-urlencode 'foo=bar?' /path, which in previous curl versions returned /path?foo=bar%3F but now returns curl: (27) Out of memory. This usage is arguably dubious to begin with, but if it is not supported, I think the error message shouldn't be "Out of memory".

curl/libcurl version

curl 7.86.0 (x86_64-pc-linux-gnu) libcurl/7.86.0 OpenSSL/3.0.7 zlib/1.2.13 brotli/1.0.9 zstd/1.5.2 libidn2/2.3.4 libpsl/0.21.1 (+libidn2/2.3.4) libssh2/1.10.0 nghttp2/1.50.0
Release-Date: 2022-10-26
Protocols: dict file ftp ftps gopher gophers http https imap imaps mqtt pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS brotli GSS-API HSTS HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM NTLM_WB PSL SPNEGO SSL threadsafe TLS-SRP UnixSockets zstd

operating system

Arch Linux

@Hello71 Hello71 changed the title curl -G --data-urlencode x / returns curl: (27) Out of memory curl -G --data x / returns curl: (27) Out of memory Nov 11, 2022
@bagder bagder self-assigned this Nov 11, 2022
bagder added a commit that referenced this issue Nov 11, 2022
If the URL that -G would try to add a query to could not be parsed, it would
display

 curl: (27) Out of memory

It now instead shows:

 curl: (2) Could not parse the URL, failed to set query

Reported-by: Alex Xu
Fixes #9889
@bagder bagder closed this as completed in 7f182f7 Nov 11, 2022
@Hello71
Copy link
Contributor Author

Hello71 commented Nov 12, 2022

Hm... as I understand, in new curl versions, https://stackoverflow.com/questions/296536/how-to-urlencode-data-for-curl-command/10797966 won't work anymore. Is there a better way to URL-encode some query string parameters and also send request body?

@bagder
Copy link
Member

bagder commented Nov 12, 2022

Hm... as I understand, in new curl versions won't work anymore.

I don't understand what you say won't work anymore. We don't break behavior. Also, not really related to this bug.

@Hello71
Copy link
Contributor Author

Hello71 commented Nov 12, 2022

sorry, I meant to link to https://stackoverflow.com/questions/296536/how-to-urlencode-data-for-curl-command/10797966#10797966. example:

date | curl -Gso /dev/null -w %{url_effective} --data-urlencode @- "" | cut -c 3-

@bagder
Copy link
Member

bagder commented Nov 13, 2022

My points remain the same. Why wouldn't that work?

@Hello71
Copy link
Contributor Author

Hello71 commented Nov 16, 2022

before b82eb72, date | src/curl -Gso /dev/null -w %{url_effective} --data-urlencode @- "" | cut -c 3- returns the current date with url encoding. after, it returns nothing.

@bagder
Copy link
Member

bagder commented Nov 16, 2022

"" is not a valid URL. If you remove the -s you'll see the error message.

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

Successfully merging a pull request may close this issue.

2 participants