Branch: Tag:

2014-01-12

2014-01-12 02:07:06 by Arne Goedeke <el@laramies.com>

Stdio.File: signed integers don't overflow in C

checking for signed overflow using (r<<1) < r does not work. the purpose
of these checks is a mystery to me, though.

674:    *err=0;       if(r <= DIRECT_BUFSIZE || -  (all && (r<<1) > r && (((r-1)|r)+1)!=(r<<1))) /* r<<1 != power of two */ +  (all && !INT32_MUL_OVERFLOW(r, 2) && (((r<<1)-1)&(r<<1)))) /* r<<1 != power of two */    {    struct pike_string *str;   
763:    b.s.str=0;    initialize_buf(&b);    SET_ONERROR(ebuf, free_dynamic_buffer, &b); -  i = all && (r<<1)>r ? DIRECT_BUFSIZE : READ_BUFFER; +  i = all && !INT32_MUL_OVERFLOW(r, 2) ? DIRECT_BUFSIZE : READ_BUFFER;    do{    int e;    char *buf;