cURL / Mailing Lists / curl-library / Single Mail


Re: curl_schannel.c and realloc()

From: Marc Hoersken <>
Date: Tue, 19 Jun 2012 22:46:32 +0200

Hi Daniel,

2012/6/19 Daniel Stenberg <>:
> I can throw in another thought too. We really should aboid unbounded
> enlargements of the buffer as it can possibly lead to a rouge server to try
> to exploit this by providing a stream that expands to something ridiculously
> large making us allocate huge chunks of memory leading to badness. So there
> should probably be a maximum. Also, we should double the buffer space for
> each loop, not just expand with bufsize/2 IMHO as that is usually what comes
> out as the better algorithm.

that sounds like a good plan. I will create a patch to implement the
buffer size ceiling and doubling.

What do you think would be a good value for such a ceiling? BUFSIZE *
10? or even 100?

> Given a ceiling as mentioned above, I think it we should leave the enlarged
> buffer allocated to avoid lots of reallocs over the course of a single
> transfer. That's what we do for several other buffers we expand in similar
> style.

Okay, in this case: could you push the patch attached in my previous
email, please? This one removes those reallocations.

List admin:
Received on 2012-06-19