Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:15341 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 63119 invoked by uid 1010); 10 Mar 2005 10:23:53 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 63104 invoked by uid 1007); 10 Mar 2005 10:23:53 -0000 Message-ID: <20050310102353.63103.qmail@lists.php.net> To: internals@lists.php.net Date: Thu, 10 Mar 2005 11:23:51 +0100 User-Agent: Debian Thunderbird 1.0 (X11/20050116) X-Accept-Language: en-us, en MIME-Version: 1.0 References: <20050310101712.GA6960@redhat.com> In-Reply-To: <20050310101712.GA6960@redhat.com> X-Enigmail-Version: 0.90.0.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 194.171.252.102 Subject: Re: [PATCH] exif warning fix? From: abies@php.net (Ard Biesheuvel) Joe Orton wrote: > Testing "length >= LONG_MAX" where length is an int is always false, and > gcc gives a warning for it. Perhaps something like this was intended? > On 64-bit it is always false, however on 32-bit 'length == LONG_MAX' can be true. That's probably why noone caught the warning so far, as gcc would not emit it on a 32-bit system. If you're testing for overflow, casting to unsigned int won't help you here, as the overflow will already have occurred when length was assigned its value. -- Ard > Index: ext/exif/exif.c > =================================================================== > RCS file: /repository/php-src/ext/exif/exif.c,v > retrieving revision 1.170 > diff -u -r1.170 exif.c > --- ext/exif/exif.c 2 Mar 2005 18:21:45 -0000 1.170 > +++ ext/exif/exif.c 10 Mar 2005 10:15:31 -0000 > @@ -1557,7 +1557,7 @@ > image_info_data *info_data; > image_info_data *list; > > - if (length >= LONG_MAX) { > + if ((unsigned int)length >= INT_MAX) { > return; > } >