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

--libcurl fails to reproduce binary data from --data-binary input that contains null bytes #6031

smuehlst opened this issue Oct 1, 2020 · 0 comments


Copy link

smuehlst commented Oct 1, 2020

I did this

I came across this when I tried to convert a curl command line tool invocation into a corresponding libcurl program. The use case was to retrieve a time-stamp from a time-stamp server. The attached file bindata.gif is only for demonstration purposes and does not contain an actual time-stamp request. The file contains null bytes and is six bytes large:

E:\Users\stm\Documents\GitHub\curl [master ≡ +4 ~0 -0 !]> wsl xxd bindata.gif
00000000: 6100 0000 0062

curl command line tool invocation:

E:\Users\stm\Documents\GitHub\curl [master ≡ +4 ~0 -0 !]> .\build\src\Debug\curl.exe --libcurl - -s -H "Content-Type: application/timestamp-query" --data-binary "@bindata.gif" -o response.tsr
/********* Sample code generated by the curl command line tool **********
 * All curl_easy_setopt() options are documented at:
  curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "a");
  curl_easy_setopt(hnd, CURLOPT_POSTFIELDSIZE_LARGE, (curl_off_t)6);

Note that the value supplied for CURLOPT_POSTFIELDSIZE_LARGE does not match the length of the data supplied via CURLOPT_POSTFIELDS.

I expected the following

I expected that the string passed via CURLOPT_POSTFIELDS contains the full data from the input file, e.g.:

curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "a\000\000\000\000b");

curl/libcurl version

Curl built from commit 7920be9.

E:\Users\stm\Documents\GitHub\curl [master ≡ +4 ~0 -0 !]> .\build\src\Debug\curl.exe -V
curl 7.73.0-DEV (Windows) libcurl/7.73.0-DEV
Release-Date: [unreleased]
Protocols: dict file ftp gopher http imap ldap mqtt pop3 rtsp smb smtp telnet tftp
Features: AsynchDNS IPv6 Largefile NTLM

operating system

Windows 10 Version 2004, but also reproduced on Linux.

bagder added a commit that referenced this issue Oct 1, 2020
Reported-by: Stephan Mühlstrasser
Fixes #6031
bagder added a commit that referenced this issue Oct 2, 2020
Reported-by: Stephan Mühlstrasser
Fixes #6031
Closes #6032
@bagder bagder self-assigned this Oct 2, 2020
@bagder bagder closed this as completed in 3997b3e Oct 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Successfully merging a pull request may close this issue.

2 participants