Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:90937 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 16571 invoked from network); 26 Jan 2016 11:38:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Jan 2016 11:38:20 -0000 Authentication-Results: pb1.pair.com smtp.mail=pierre.php@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=pierre.php@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.53 as permitted sender) X-PHP-List-Original-Sender: pierre.php@gmail.com X-Host-Fingerprint: 74.125.82.53 mail-wm0-f53.google.com Received: from [74.125.82.53] ([74.125.82.53:33283] helo=mail-wm0-f53.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1D/05-10534-BAA57A65 for ; Tue, 26 Jan 2016 06:38:19 -0500 Received: by mail-wm0-f53.google.com with SMTP id 123so102045411wmz.0 for ; Tue, 26 Jan 2016 03:38:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=TCMcLiMI1W5OBm+Gom8CIGrCzIprI/7TaSy8DSdkm7w=; b=S56id6lngaj067gxNqSevdOcgCBagW0ssNXXEP8bo1OB0zg9ATlUoJhTiLRFEitws1 3qZyFEVvAF5z2cfE9vsXki7x9NzEHblopvK2UEMgw1BGGkBIqsIUrZy4mEngsEfytYFS S8vqhMVUlSG0FnVn7cdU8yw6IH0/dJb7LU3rWcNIxYDk5viJociTRo7eL0bseRKw9XMv Z5buF2XbIJXGSTdzC9oGHx9KjfrZ4ry5AI5BwY7SgcZghridMJlmQUfBK5pOrh2KVSmq hz67d4S1KMn59GJtpNQoteupEjEztm3sgqWDBsYIwaeRul2/AvoR8cuRcRQ9e48RRPk4 kAlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=TCMcLiMI1W5OBm+Gom8CIGrCzIprI/7TaSy8DSdkm7w=; b=X/5I97tPo00Qn8tVzuC+K32ahBj7Q+8FQpDVKJ4pfuaGWyPAqv+9HcAsvZPVnK5NK7 sIPSQPuPumbk+TtPTeDRLge7lVY5TBD7f7Zmxf/zjANgVeg1w8lrlE+O32IyRz/Nhhq4 RWL/z9gh+ivU8fmz4tJCJxW8wfa1fr+00EaMIX1gFl2maa9YrxGMxPwKR5d4NFpG1FGE e5GxI/c5ee1GapvBRfN3wSGS902RpvzYT/8XoCawuN7W1nu2QK8Fhzgbwm6Jv18eb/MV uT4/c4hyhJbLVp4wZOm7Ojv1W4T7U7K9IFzEopacJA2w6DjtHFJHtbRHFHuiZ96rxvbD BdoQ== X-Gm-Message-State: AG10YOQCQVIoHQ22nRcu3UACmtGFmwO3QejXRCbdXkurnwF4TwU3fKRPOXR8stw9QVAZcb1A+pCBVZspnK7pLA== MIME-Version: 1.0 X-Received: by 10.28.111.194 with SMTP id c63mr24485361wmi.90.1453808296424; Tue, 26 Jan 2016 03:38:16 -0800 (PST) Received: by 10.28.148.5 with HTTP; Tue, 26 Jan 2016 03:38:16 -0800 (PST) Received: by 10.28.148.5 with HTTP; Tue, 26 Jan 2016 03:38:16 -0800 (PST) In-Reply-To: References: <9D.00.64206.7C430A65@pb1.pair.com> <0D.E3.12955.15522A65@pb1.pair.com> Date: Tue, 26 Jan 2016 18:38:16 +0700 Message-ID: To: Julien Pauli Cc: PHP internals , Umberto Salsi , Daniel Lowrey , Yasuo Ohgaki Content-Type: multipart/alternative; boundary=001a11477e36147d7e052a3b1fe5 Subject: Re: [PHP-DEV] Severe safety fail in file access and stream filters From: pierre.php@gmail.com (Pierre Joye) --001a11477e36147d7e052a3b1fe5 Content-Type: text/plain; charset=UTF-8 On Jan 26, 2016 5:50 PM, "Julien Pauli" wrote: > > On Tue, Jan 26, 2016 at 5:15 AM, Yasuo Ohgaki wrote: > > Hi Umberto, > > > > On Fri, Jan 22, 2016 at 9:49 PM, Umberto Salsi wrote: > >> thank you very much for the reply, I now start understanding better what > >> happen and why currently i/o cannot be handled in user's space. > > > > You're welcome. > > I think you have pointed out important missing parts in PHP. > > > >> Rather than an array of error, which might be quite expensive to handle, > >> why not a simple "char * lasterror" field added to the stream struct, > >> normally set to NULL, where a description of the last error occurred may > >> be stored? The high-level functions, that is PHP fopen, fread, fwrite, > >> fflush, fseek, fclose, may then check that string and, if set, trigger > >> E_WARNING with a meaningful message after having reset that string back > >> to NULL again. Many C libraries already provide such error strings, > >> starting from the same C strerror(). > > > > Pgsql's "notice" logging is implemented this way at first. Then I changed > > it to array of notices recently. (Notice is raised during > > transaction, for example) > > > > It's very difficult or impossible to detect where something wrong happened > > if there is only the last error. That's the reason why pgsql module is changed > > to have array of notices. > > > > The same would happen in streams, so it's better to store all errors during > > operation. Zend hash is extremely fast and good enough for logging errors, > > so we don't have to worry overheads. > > > >> > >> The same should then be done with the filters, which currently only may > >> return PSFS_ERR_FATAL, but might have their "char * lasterror" string > >> too with the same purpose. Knowing the exact reason of the failure is > >> essential to distinguish, for example, a dead disk drive or corrupted file > >> system, from a bare file mistakenly opened with the wrong decompressor > >> or a file which was badly encoded. > > > > I agree. > > > >> > >> Then all the specific stream and filter implementations can be adjusted > >> to set that error string; for those still not fixed that string remains > >> NULL and fopen, ferror, etc. will not report the error just as they do > >> today, and will be fixed later step by step. > > > > Agree here, too. > > Someone have to volunteer for this. It's not difficult for people on this list. > > I have too many backlogs for PHP project, so I hope someone volunteers > > for this. > > > > Regards, > > > > -- > > Yasuo Ohgaki > > yohgaki@ohgaki.net > > > > -- > > PHP Internals - PHP Runtime Development Mailing List > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > I think what we should do is sit around the table with people > interested (Daniel Lowrey may be one of them), and plan a full rewrite > of streams for PHP next major (PHP 8). I don't think addind stuff to > next minors is a good idea, knowing we must prevent BC breaks in such > versions. We'll probably have to introduce some BC breaks is our tidy. > > All our stream API is missing lots of features, and failing in many parts. > > We could as well add to the reflection Async I/O and scatter/gather, > something I already thought about > for PHP 7, but found no time nor motivation nor friend contributors to > push to the level of quality we expect it for PHP. > > While beeing perfectly valid, fixing just one little problem among > many others is not a durable solution for our stream API, > which is old, patched everywhere, but pretty stable and serving its > purpose as-is. > > There are lots of problems in extensions as well, regarding streams, > where it is far from beeing easy to change one of the stream layer > behavior, or implement your own. > This should get addressed as well. I totally agree with you here. The same applies imho to the session (about the other rfc targetting 7.1 or other). --001a11477e36147d7e052a3b1fe5--