This is the mail archive of the cygwin mailing list for the Cygwin project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Hi, recently I stumbled across a bug in curl for 64-bit Cygwin regarding the -i option. This bug has already been discussed in April 2013: http://cygwin.1069669.n5.nabble.com/Difference-in-32-64-bit-curl-td98083.html (I can't reply directly since I was not subscribed to this mailinglist back then.) The problem is that the current version of curl always includes the protocol headers in the output (no matter if -i or --include or --no-include are used or not). This bug breaks scripts which use curl and expect it to not include the headers in the output. After some debugging I found out that the cause of the problem is a missing cast of the third argument of my_setopt in tool_operate.c:886 (line numbers from curl 7.29.0) my_setopt(curl, CURLOPT_HEADER, config->include_headers); Here, config->include_headers is of type bool (1 byte) and my_setopt is a macro which calls curl_easy_setopt() and is defined in tool_setopt.h as follows: #define my_setopt(x,y,z) \ SETOPT_CHECK(tool_setopt(x, FALSE, config, #y, y, z)) tool_setopt() is implemented in tool_setopt.c and uses va_arg(arg, long) to get the value of its sixth argument (which is config->include_headers). However, sizeof(long) == 8, but sizeof(bool) == 1 and thus va_arg(arg, long) returns a value != 0 even if config->include_headers == 0. I am not sure why there is no problem with other boolean configuration options like CURLOPT_FAILONERROR (corresponding to -f or --fail) which are processed in exactly the same way, e.g., in tool_operate.c:930 my_setopt(curl, CURLOPT_FAILONERROR, config->failonerror); Also, there is no problem in 32-bit Cygwin and in 32/64-bit Linux. Maybe the bug is triggered by some missing or incorrect (alignment related) compiler switches? Anyway, I have attached an updated cygport file together with a patch to fix this bug (tested with cygport --32 and cygport --64). @Yaakov: Could you please test my patch and update the curl package? Best regards, Andreas
Attachment:
curl.cygport
Description: Text document
diff -uNpr curl-7.29.0/src/tool_operate.c curl-7.29.0/src/tool_operate.c --- curl-7.29.0/src/tool_operate.c 2013-02-06 10:47:19.000000000 +0100 +++ curl-7.29.0/src/tool_operate.c 2013-08-11 21:21:47.397377700 +0200 @@ -877,13 +877,13 @@ int operate(struct Configurable *config, my_setopt(curl, CURLOPT_NOPROGRESS, config->noprogress); if(config->no_body) { my_setopt(curl, CURLOPT_NOBODY, 1); - my_setopt(curl, CURLOPT_HEADER, 1); + my_setopt(curl, CURLOPT_HEADER, (long)1); } /* If --metalink is used, we ignore --include (headers in output) option because mixing headers to the body will confuse XML parser and/or hash check will fail. */ else if(!config->use_metalink) - my_setopt(curl, CURLOPT_HEADER, config->include_headers); + my_setopt(curl, CURLOPT_HEADER, (long)config->include_headers); #if !defined(CURL_DISABLE_PROXY) {
Attachment:
signature.asc
Description: OpenPGP digital signature
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |