[64-bit] curl: fix -i option (include headers)

Andreas Winkelbauer andreas.winkelbauer@nt.tuwien.ac.at
Sun Aug 11 20:36:00 GMT 2013


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

-------------- next part --------------
NAME="curl"
VERSION=7.29.0
RELEASE=1
CATEGORY="Net Web"
SUMMARY="Multi-protocol file transfer tool"
DESCRIPTION="curl is a command line tool and library for transferring files
with URL syntax, supporting FTP, FTPS, HTTP, HTTPS, SCP, SFTP, TFTP,
TELNET, DICT, and FILE. curl supports SSL certificates, HTTP POST, HTTP
PUT, FTP uploading, HTTP form based upload, proxies, cookies,
user+password authentication (Basic, Digest, NTLM, Negotiate...), file
transfer resume, proxy tunneling and a busload of other useful tricks."
HOMEPAGE="http://curl.haxx.se/"
SRC_URI="http://curl.haxx.se/download/${P}.tar.lzma"

PKG_NAMES="${PN} lib${PN}4 lib${PN}-devel"
curl_CONTENTS="usr/bin/curl.exe usr/share/doc/ usr/share/man/man1/curl.*"
libcurl4_SUMMARY="Multi-protocol file transfer library (runtime)"
libcurl4_CONTENTS="usr/bin/cygcurl-4.dll"
libcurl_devel_SUMMARY="Multi-protocol file transfer library (development)"
libcurl_devel_CONTENTS="usr/bin/curl-config usr/include/ usr/lib/
                        usr/share/man/man1/curl-config.* usr/share/man/man3/"

PATCH_URI="include-headers-cygwin.patch"

DIFF_EXCLUDES="Makefile curlbuild.h curl_config.h"

# librtmp: not in Fedora due to unchallenged DMCA action
CYGCONF_ARGS="
	--enable-debug --enable-optimize
	--disable-hidden-symbols
	--disable-ares
	--enable-ldap
	--disable-sspi
	--with-gssapi
	--without-krb4
	--with-libidn
	--with-libmetalink
	--without-librtmp
	--with-libssh2
	--without-spnego
	--with-ssl
	--with-zlib
	--with-ca-bundle=/usr/ssl/certs/ca-bundle.crt
"

DOCS="docs/BINDINGS docs/BUGS docs/CONTRIBUTE docs/DISTRO-DILEMMA docs/FAQ
      docs/FEATURES docs/HISTORY docs/HTTP-COOKIES docs/INTERNALS docs/KNOWN_BUGS
      docs/LICENSE-MIXING docs/MAIL-ETIQUETTE docs/MANUAL docs/RESOURCES
      docs/SSLCERTS docs/THANKS docs/TheArtOfHttpScripting docs/TODO docs/VERSIONS"

KEEP_LA_FILES="none"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: include-headers-cygwin.patch
Type: text/x-patch
Size: 961 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20130811/0ceb2964/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 899 bytes
Desc: OpenPGP digital signature
URL: <http://cygwin.com/pipermail/cygwin/attachments/20130811/0ceb2964/attachment.sig>


More information about the Cygwin mailing list