cURL / Mailing Lists / curl-library / Single Mail


Re: cURL bug -- Segmentation Fault when timeout is 1 second

From: Daniel Marschall <>
Date: Wed, 4 Feb 2009 19:12:16 +0100


I will try to extend the writer-function, so that it extends the buffer.

But the website is a text-only page. So it should
not be that my buffer has binary data at the beginning. And please look at
my code and output:
- The first call did output the website correctly
- The second call had binary garbage at the beginning
- The third call had other binary garbage at the beginning
And every call should be the same since the functionality is independent of

I never used strncpy() or any similar function in my codes. Maybe you have
looked at the wrong example code? I used the example code of the
writer function that used std::string->append().

Daniel Marschall

From: "Gary Maxwell" <>
Sent: Wednesday, February 04, 2009 7:01 PM
To: "libcurl development" <>
Subject: RE: cURL bug -- Segmentation Fault when timeout is 1 second

> Daniel Marschall on February 04, 2009 9:49 AM wrote:
>> But there are 2 problems I still have:
>> 1. I want to have an infinite big buffer, like a std::string in C++.
> If
>> the
>> website-output is larger than the buffer size, then I get a
>> memory-access-error again.
>> Isn't "char*" an infinite c-string that waits for an 0x0 termination
>> sequence, is it?
> "char*" is certainly NOT an infinite c-string. It is simply a pointer
> to an area of memory that contains sequential characters, the
> size of which you determine when you statically define or dynamically
> allocate the memory.
> You can easily expand the size of your buffer in the write callback
> function. Look at the documentation for realloc().
>> 2. The output of the buffer with printf() is not correct. Some foreign
>> memory contents are in my string... The output is like:
> Whoever said that the response from the server would be printable
> UTF-8 data? The server will send back whatever data it thinks you asked
> for, be it text, images, or sound bites. This is what particularly
> alarmed me in your earlier example code, using strncpy() in the write
> callback. You should instead use memcpy().
> -GaryM at casabi
Received on 2009-02-04