Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:23974 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 69919 invoked by uid 1010); 7 Jun 2006 07:56:21 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 69904 invoked from network); 7 Jun 2006 07:56:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Jun 2006 07:56:21 -0000 X-PHP-List-Original-Sender: antony@zend.com X-Host-Fingerprint: 80.74.107.235 mail.zend.com Linux 2.5 (sometimes 2.4) (4) Received: from ([80.74.107.235:6119] helo=mail.zend.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 0D/27-00946-4A686844 for ; Wed, 07 Jun 2006 03:56:21 -0400 Received: (qmail 22737 invoked from network); 7 Jun 2006 07:55:49 -0000 Received: from internal.zend.office (HELO ?127.0.0.1?) (10.1.1.1) by internal.zend.office with SMTP; 7 Jun 2006 07:55:49 -0000 Message-ID: <4486869C.7000408@zend.com> Date: Wed, 07 Jun 2006 11:56:12 +0400 User-Agent: Thunderbird 1.5.0.4 (X11/20060516) MIME-Version: 1.0 To: john CC: internals@lists.php.net References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Binary searches From: antony@zend.com (Antony Dovgal) On 07.06.2006 03:06, john wrote: > Attached is a patch which addresses array indices being out of bounds in > pcre and libxmlrpc binary searches. Please elaborate. What exactly are you fixing and how to reproduce it? > ------------------------------------------------------------------------ > > Index: ext/pcre/pcrelib/pcre_get.c > =================================================================== > RCS file: /repository/php-src/ext/pcre/pcrelib/pcre_get.c,v > retrieving revision 1.2 > diff -u -r1.2 pcre_get.c > --- ext/pcre/pcrelib/pcre_get.c 6 Mar 2006 21:34:07 -0000 1.2 > +++ ext/pcre/pcrelib/pcre_get.c 6 Jun 2006 22:59:42 -0000 > @@ -79,9 +79,10 @@ > return rc; > > bot = 0; > +int mid = 0; > while (top > bot) > { > - int mid = (top + bot) / 2; > + mid = ((unsigned) top + bot) >> 1; > uschar *entry = nametable + entrysize*mid; > int c = strcmp(stringname, (char *)(entry + 2)); > if (c == 0) return (entry[0] << 8) + entry[1]; > Index: ext/xmlrpc/libxmlrpc/queue.c > =================================================================== > RCS file: /repository/php-src/ext/xmlrpc/libxmlrpc/queue.c,v > retrieving revision 1.4 > diff -u -r1.4 queue.c > --- ext/xmlrpc/libxmlrpc/queue.c 5 Jul 2002 04:43:53 -0000 1.4 > +++ ext/xmlrpc/libxmlrpc/queue.c 6 Jun 2006 22:59:44 -0000 > @@ -859,7 +859,7 @@ > hi = q->size - 1; > > while(low <= hi) { > - mid = (low + hi) / 2; > + mid = ((unsigned) (low + high)) >> 1; > val = Comp(key, index[ mid ]); > > if(val < 0) > > -- Wbr, Antony Dovgal