cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Impossible to POST binary data with CURLOPT_POSTFIELDS

From: Colin Hogben <curl_at_pythontech.co.uk>
Date: Fri, 12 Oct 2007 09:15:01 +0100

Dan Fandrich wrote:
> I'm suggesting first strduping the data as is presently done
> when the CURLOPT_POSTFIELDS comes in, then copying it again when the size
> comes in the size is different from what we copied. In the case of a
> normal C string, the size will be the same and the second copy won't
> happen.
>
I think there is a potential risk if the user wishes to post a small
amount of binary data which contains no NUL, by setting
CURLOPT_POSTFIELDS first and then the size later. Trying to strdup it
will run off the end, maybe for megabytes if there no NUL byte anywhere
soon after it in memory, or you could reach an address which causes a
memory exception.

-- 
Colin Hogben
Received on 2007-10-12