I'm using visual studio 2013.
With a 64 bit compile size_t is an 8 byte value.
ssize_t which is typedefed as long is a 4 byte value;
I don't think this is specific to visual studio however some Unix systems
probably allocate long as 8 bytes in a 64bit build.
Given the existing code listed below:
Begin code fragment:
CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
char *datap,
ssize_t datalen,
ssize_t *wrotep)
{
CURLcode result=CURLE_OK;
struct SessionHandle *data = conn->data;
struct Curl_chunker *ch = &conn->chunk;
struct SingleRequest *k = &data->req;
size_t piece;
curl_off_t length = (curl_off_t)datalen;
size_t *wrote = (size_t *)wrotep;
*wrote = 0; /* nothing's written yet */
End code fragment:
The assignment to *wrote writes 8 bytes to the location pointed to by wrotep
which is only allocated 4 bytes by the compiler.
With 32 bit code size_t is the same size as ssize_t (long) which is 4 bytes and
there is no issue.
To repeat the issue in visual studio compile libcurl in a Debug|x64
configuration with /RTC1 and /GS options.
In my case the Run-Time check fails at the return of readwrite_data in
transfer.c when a CHUNKED transfer occurs.
The failure message lists stack corruption around the variable nread.
Glen Johnson
Phone: 321-696-3122
Email: [email protected]
-----Original Message-----
From: curl-library [mailto:[email protected]] On Behalf Of
[email protected]
Sent: Sunday, July 20, 2014 6:00 AM
To: [email protected]; [email protected]
Subject: curl-library Digest, Vol 107, Issue 56
Send curl-library mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-library
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific than "Re:
Contents of curl-library digest..."
Today's Topics:
1. Re: Issue with http_chunks.c (Daniel Stenberg)
----------------------------------------------------------------------
Message: 1
Date: Sat, 19 Jul 2014 23:36:07 +0200 (CEST)
From: Daniel Stenberg <[email protected]>
To: libcurl development <[email protected]>
Subject: Re: Issue with http_chunks.c
Message-ID: <[email protected]>
Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII
On Sat, 19 Jul 2014, Glen A Johnson Jr. wrote:
> This issue was discovered when running with a 64bit compilation.
>
> The assignment of a ssize_t pointer from the parameter list to a
> size_t pointer in the function causes stack corruption when data is
> assigned to the variables location during 64bit execution.
How does that happen? Are you suggesting size_t and ssize_t use different sizes
for you?
> The diff file attached shows one method to correct the issue. A
> simpler method would be to eliminate the variable "wrote" and use
> "*wrotep += (ssize_t)piece;" at ~line 237.
Can you elaborate on what is needed and why, in plain English? Also, what can
we do to repeat the problem you saw with this?
--
/ daniel.haxx.se
------------------------------
Subject: Digest Footer
_______________________________________________
curl-library mailing list
[email protected]
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-library
------------------------------
End of curl-library Digest, Vol 107, Issue 56
*********************************************
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html