cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Potential integer overflow with write callback

From: Alan Wolfe <alan.wolfe_at_gmail.com>
Date: Sat, 26 Mar 2011 18:48:14 -0700

16 bits?? thats tiny.... you sure about that?

fwiw size_t is 64 bits on my machine

On Sat, Mar 26, 2011 at 6:37 PM, <richardcavell_at_mail.com> wrote:
> Hi everyone,
>
> My write callback function looks like this:
>
> size_t writehttpcallback ( void *ptr, size_t size, size_t nmemb, void *data)
> {
>  size_t realsize = size*nmemb;
>   ...
>  return realsize;
> }
>
> Now, size_t is guaranteed only to be at least 16 bits according to the
> standard, which means that if realsize turns out to be more than 64
> kilobytes, it might overflow.  I'm assuming that it's not unheard of to get
> 64 kilobytes in an HTTP transaction.
>
> Does the library account for possible overflows?  Or do I have to detect
> them myself?
>
> Richard
>
>
>
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-library
> Etiquette:  http://curl.haxx.se/mail/etiquette.html
>

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-03-27