Use <intprops.h> within glibc for integer overflow checks?
Andreas Jaeger
aj@suse.com
Thu May 16 14:40:00 GMT 2013
On 05/15/2013 11:42 PM, Paul Eggert wrote:
> On 05/15/13 09:58, Nickolai Zeldovich wrote:
>> +#define __HALF_MAX_SIGNED(type) \
>> + ((type)1 << (sizeof(type)*8-2))
>> +#define __MAX_SIGNED(type) \
>> + (__HALF_MAX_SIGNED(type) - 1 + __HALF_MAX_SIGNED(type))
>> ...
>> - if (offset + len < 0)
>> + if (offset > __MAX_SIGNED(__off_t) - len)
>
> At some point perhaps glibc should steal the <intprops.h>
> header from gnulib, for internal use. That way, the above
> code could be simplified to:
Good idea, I'll add it to the Todo list at:
http://sourceware.org/glibc/wiki/Development_Todo/Master
Andreas
--
Andreas Jaeger aj@{suse.com,opensuse.org} Twitter/Identica: jaegerandi
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn,Jennifer Guild,Felix Imendörffer,HRB16746 (AG Nürnberg)
GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126
More information about the Libc-alpha
mailing list