Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85900 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 16897 invoked from network); 22 Apr 2015 12:19:06 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Apr 2015 12:19:06 -0000 Authentication-Results: pb1.pair.com header.from=julienpauli@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=julienpauli@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.45 as permitted sender) X-PHP-List-Original-Sender: julienpauli@gmail.com X-Host-Fingerprint: 74.125.82.45 mail-wg0-f45.google.com Received: from [74.125.82.45] ([74.125.82.45:36055] helo=mail-wg0-f45.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7E/21-10126-8B197355 for ; Wed, 22 Apr 2015 08:19:06 -0400 Received: by wgen6 with SMTP id n6so29857289wge.3 for ; Wed, 22 Apr 2015 05:19:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=HJu4nxQbYdRoGGkKyWsz4d2nC5tBSrXitZeAZj+P/qw=; b=kbAPKaNHX2oZ0d0+Gh0bTPl0unGRk3FkPbn0tjpcYKFLxHqgjltMdnzNwdKchDKkVg COhRmwXgDxbGt1SigcsSLiioBIV+HVeBDTKEKu9IrLjxUmtQKuQyLpFDJ5MG7R2Uau7H y+tJ0RSc6oRCK9ogXVcLWJRRwTY7tVzAAx1v1oBFIpALc3xhgnz764h3ICH9ICFRAtJI 7u+gJ7PV4If4FEC/0CAF8XbOGVIxd8FV+MEW4J5+e3+1aXMXZzXYsWMgaJFVOAXG6fAM hqYhhy0gDTqa06QXNSazfSx5kKpGFytiWMVbD1Gag2wjmeUXaS2inq01bpjBxWxUnZSC TNiQ== X-Received: by 10.194.171.199 with SMTP id aw7mr15129119wjc.64.1429705141552; Wed, 22 Apr 2015 05:19:01 -0700 (PDT) MIME-Version: 1.0 Sender: julienpauli@gmail.com Received: by 10.194.198.210 with HTTP; Wed, 22 Apr 2015 05:18:21 -0700 (PDT) In-Reply-To: <55342A50.9030100@gmail.com> References: <55342A50.9030100@gmail.com> Date: Wed, 22 Apr 2015 14:18:21 +0200 X-Google-Sender-Auth: 9jV3tTdK2l-EyCcW-SmKn4beBsw Message-ID: To: Stanislav Malyshev Cc: Andrew Faulds , PHP Internals Content-Type: multipart/alternative; boundary=089e0122ec88188fe805144f2b7d Subject: Re: [PHP-DEV] Closure::call() to access private data, really ? From: jpauli@php.net (Julien Pauli) --089e0122ec88188fe805144f2b7d Content-Type: text/plain; charset=UTF-8 On Mon, Apr 20, 2015 at 12:21 AM, Stanislav Malyshev wrote: > Hi! > > > Just a simple use case showing how dangerous that is : > > > > > $p = function($p) { $this->$p = new Stdclass; }; > > $p->call($e = new Exception, 'trace'); > > throw $e; > > Yes, this is not good, and this is the consequence of allowing to rebind > closures. I'm not sure though how to fix it except for banning closures > from assuming scope of internal classes. If you assigned the scope of > Exception to it, it should have access to Exception - that's how the > scope works. > > > For User classes, this could lead to information leaks or bad behaviors, > > I'm not sure what you mean by "information leaks", but the behavior is > on whoever wrote that code. People can write bad code, we can't disallow > this. We can restrict things that would really break (like segfault) but > I'm not sure what else we can do here. If you have the scope of the > class, that implies access to the private members of the class. So we > either have to not let the closure have the scope, or invent some > additional term of scope' that is not like real scope. I don't think > it'd be good. > Yup Stas. Perhaps the best thing to do is to forbid rebinding a Closure to an internal class ? I'm sure we could find segfaulting behaviors using such a trick on most of our internals classes, aka mysqli, simplexmlelement, PDO or SPL classes. Thoughts ? Julien.P --089e0122ec88188fe805144f2b7d--