Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:90927 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 84996 invoked from network); 26 Jan 2016 04:16:24 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Jan 2016 04:16:24 -0000 Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.160.177 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.160.177 mail-yk0-f177.google.com Received: from [209.85.160.177] ([209.85.160.177:34715] helo=mail-yk0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3F/B0-10534-713F6A65 for ; Mon, 25 Jan 2016 23:16:23 -0500 Received: by mail-yk0-f177.google.com with SMTP id a85so186919082ykb.1 for ; Mon, 25 Jan 2016 20:16:23 -0800 (PST) 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=7cK3+R279xlMKafDQbQhsvcKDqB3bp4eTL03edishrQ=; b=iVbJwpIsO1zelUZvCZ/h4z7GNH6NGrNeZIqa1OB78KiphfWOIJCQw3adQaKSEvy8ui orlAwQVCIMWqaahmvqIenNkGxEgT3HILJRjusH6WW5EzmnvbbhyGV2tJyUDzj3fKikhS qmc6gq3xLjX3j6y+l55ZXjHEU5PdCNej8/nE4WW5oIzV0ZiQILUMMhwHAzb0th4SLBZT WcJOcwEA8QW3olJtv3ji2dVglkKQkRIpgXL7zglq3R/AkoqGPdW6j1vCmO8srwVCmShs 1amiHYu/73RzLtnvT5CcPt/a/1N1PvZvOi++1G7XnFsGeGXsyYS/Jpaydn0vKaKpPRLQ E4Lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc:content-type; bh=7cK3+R279xlMKafDQbQhsvcKDqB3bp4eTL03edishrQ=; b=jk7N9q4TLIqQFBNx1gvOFL4FoYKLh7WReBW+hjhk7Ep+hYm8ms4mF0Qm3oUOSyQXWI qgdhwhnQ+MDmAMmADiDniZR6FgL+BQ1y2Hemmxgx+Y+1o5VGWZnexdn9phGkC/6/cRXI lb84URAVNzOQgBHR0pvwUuUyjMZBtR+dz116ZgjQyEW7dYEQ2lJiTNShgFKA/E5JACdb Elydd96E1SaNBpbX7UNUIwwS0In7HciHKizBR59c3of9DKQLpmAv2Ic7+pRq/hVIdN0T 6c4RVPWHKopaEPajU3iTODxlEBFTdeo1mVSEITpa1BVd5oNBzwo1k+QBfiFauqhgBbd6 b4vA== X-Gm-Message-State: AG10YOQ+kNOrdmhLhNeme7x9ZwbWVGgujI8jhEHjw4Ta8/rfmDrzlSC/uUuGy3VHF5wsd6tjcVr+DauTWuIZkw== X-Received: by 10.37.28.69 with SMTP id c66mr11001298ybc.159.1453781779908; Mon, 25 Jan 2016 20:16:19 -0800 (PST) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.129.88.139 with HTTP; Mon, 25 Jan 2016 20:15:40 -0800 (PST) In-Reply-To: <0D.E3.12955.15522A65@pb1.pair.com> References: <9D.00.64206.7C430A65@pb1.pair.com> <0D.E3.12955.15522A65@pb1.pair.com> Date: Tue, 26 Jan 2016 13:15:40 +0900 X-Google-Sender-Auth: heszxiR4mq6hiIjB237JBKyGRZ4 Message-ID: To: Umberto Salsi Cc: "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Severe safety fail in file access and stream filters From: yohgaki@ohgaki.net (Yasuo Ohgaki) 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