[Developers] [Patches] fix to integer overflow bug in PUGH

Erik Schnetter schnetter at cct.lsu.edu
Fri Apr 6 18:13:55 CDT 2007


That works only when you can guarantee that a size_t fits into an  
unsigned long.  This may not be true in general.  You could use  
unsigned long long instead, but this type does not exist on all  
platforms.

If the value fits into a double, i.e., if you have less than about  
10^15, then a double is exact.

-erik

On Apr 7, 2007, at 00:33:23, Rideout, David P wrote:

> How about casting it to an unsigned long instead?  (Just because in  
> principle one may be interested in the exact value.)
>
> -David
>
>
> -----Original Message-----
> From: developers-bounces at cactuscode.org on behalf of Erik Schnetter
> Sent: Fri 06-Apr-07 11:21 PM
> To: developers at cactuscode.org
> Subject: Re: [Developers] [Patches] fix to integer overflow bug in  
> PUGH
>
> On Apr 6, 2007, at 15:36:25, David Rideout wrote:
>
>> The malloc calls in PUGH compute the size to allocate from an int
>> expression. This patch casts such expressions to size_t.  This
>> fixes PR 2088.
>>
>> Patch also includes a check that malloc returns a non-NULL result...
>
> The patch looks fine with one exception.  You cannot print a value of
> type size_t with %lu.  I suggest to convert the value to double and
> to print it with %f instead.
>
> -erik
>
> -- 
> Erik Schnetter <schnetter at cct.lsu.edu>
>
> My email is as private as my paper mail.  I therefore support  
> encrypting
> and signing email messages.  Get my PGP key from www.keyserver.net.
>
>
>
>
>
> <winmail.dat>
> _______________________________________________
> Developers mailing list
> Developers at cactuscode.org
> http://www.cactuscode.org/mailman/listinfo/developers


-- 
Erik Schnetter <schnetter at cct.lsu.edu>

My email is as private as my paper mail.  I therefore support encrypting
and signing email messages.  Get my PGP key from www.keyserver.net.



-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: This is a digitally signed message part
Url : http://www.cactuscode.org/pipermail/developers/attachments/20070407/7222ec21/attachment-0001.bin 


More information about the Developers mailing list