Re: com php-src: Fix potential segfault: Zend/zend_list.c

From: Date: Tue, 14 Jul 2015 17:39:10 +0000
Subject: Re: com php-src: Fix potential segfault: Zend/zend_list.c
References: 1 2  Groups: php.cvs 
Request: Send a blank email to php-cvs+get-87993@lists.php.net to get a copy of this message
On 07/14/2015 02:57 AM, Nikita Popov wrote: > On Tue, Jul 14, 2015 at 4:38 AM, Rasmus Lerdorf <rasmus@php.net > <mailto:rasmus@php.net>> wrote: > > Commit: 1ce4e8c45ede395db9b3c2d157dbeb29a28830c5 > Author: Rasmus Lerdorf <rasmus@lerdorf.com > <mailto:rasmus@lerdorf.com>> Mon, 13 Jul > 2015 19:38:55 -0700 > Parents: bce9368dfbd2b11258601604a44e2145c9bb2d86 > Branches: master > > Link: > > http://git.php.net/?p=php-src.git;a=commitdiff;h=1ce4e8c45ede395db9b3c2d157dbeb29a28830c5 > > Log: > Fix potential segfault > > Changed paths: > M Zend/zend_list.c > > > Diff: > diff --git a/Zend/zend_list.c b/Zend/zend_list.c > index 261489b..c2cd606 100644 > --- a/Zend/zend_list.c > +++ b/Zend/zend_list.c > @@ -102,11 +102,11 @@ ZEND_API zend_resource* > zend_register_resource(void *rsrc_pointer, int rsrc_type > > ZEND_API void *zend_fetch_resource2(zend_resource *res, const char > *resource_type_name, int resource_type1, int resource_type2) > { > - if (resource_type1 == res->type) { > + if (res && resource_type1 == res->type) { > return res->ptr; > } > > - if (resource_type2 == res->type) { > + if (res && resource_type2 == res->type) { > return res->ptr; > } > > > In what context does this occur? Wouldn't it be better to fix the > call-site to not do this call on a bogus resource? My worry is that it might be hard to chase down all the places that might do it and a single null check doesn't seem very expensive. Try this without the patch: php -r 'pg_escape_literal("a");' -Rasmus

« previous php.cvs (#87993) next »