Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:56771 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 88415 invoked from network); 4 Dec 2011 17:29:05 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Dec 2011 17:29:05 -0000 Authentication-Results: pb1.pair.com header.from=laruence@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=laruence@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.42 as permitted sender) X-PHP-List-Original-Sender: laruence@gmail.com X-Host-Fingerprint: 209.85.212.42 mail-vw0-f42.google.com Received: from [209.85.212.42] ([209.85.212.42:50709] helo=mail-vw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 50/94-65129-EDDABDE4 for ; Sun, 04 Dec 2011 12:29:03 -0500 Received: by vbbfd1 with SMTP id fd1so3545788vbb.29 for ; Sun, 04 Dec 2011 09:29:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=idXA2edzdHmY++z8r2BydiTu/yOyI+HY46x/uGFylB8=; b=QoqSPilLMjF2lH2ajQ0vguXFcy/tjFnpZz4MpirKEwBguQxjqYkA9Dkz6yqHmv4ZZR ooZCLqJQohEKGwgr6PJEKigHxgLUWohcWOtEHhdP3foxZcPeSqaQuhctWaigffaSdMwZ gUlGvxjoP26Z7dTdT/WwQTvfiXfFuPsMHs/rg= Received: by 10.52.36.109 with SMTP id p13mr3008118vdj.59.1323019739570; Sun, 04 Dec 2011 09:28:59 -0800 (PST) MIME-Version: 1.0 Sender: laruence@gmail.com Received: by 10.220.108.7 with HTTP; Sun, 4 Dec 2011 09:28:38 -0800 (PST) In-Reply-To: References: <4EDA4989.2010702@akbkhome.com> Date: Mon, 5 Dec 2011 01:28:38 +0800 X-Google-Sender-Auth: tQS2UZ8RJvWxxHHrqt7EGWZ3ou8 Message-ID: To: Ferenc Kovacs Cc: Alan Knowles , PHP Internals List Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Fixing string offsets of strings. From: laruence@php.net (Laruence) Hi: I have submit a new patch based on the origin patch, which only trigger notice when string offset cast occurred. thanks On Sun, Dec 4, 2011 at 10:25 PM, Laruence wrote: > +1. > > thanks. > > On Sun, Dec 4, 2011 at 10:05 PM, Ferenc Kovacs wrote: >> On Sat, Dec 3, 2011 at 5:08 PM, Alan Knowles wrote: >> >>> I've had a look at making string offsets of strings a bit saner. >>> >>> At present with the fix for array dereferencing : =C2=A0?search=3Dhello= and a >>> test like isset($_GET['search']['name']) =C2=A0results in true, which i= s has >>> potential security problems and is very confusing for any programmer >>> finding and working out why something like that may be failing. >>> >>> To solve this quite a few people agreed that not allowing non-numeric >>> string offsets on strings would be the smart way to go, the change is g= oing >>> to break BC, so the idea is to at least not break it too badly... >>> >>> This patch is a start. >>> https://bugs.php.net/patch-**display.php?bug_id=3D60362&** >>> patch=3Dfirst_effort_to_fix_**this&revision=3Dlatest >>> >>> It's been quite a while since I hacked on the engine, so the patch only >>> works reasonably well.. (see the FIXME on the tests at the bottom of th= e >>> patch.) >>> >>> The patch changes the following: >>> =C2=A0* $s =3D "string"; =C2=A0$s['offset'] -- produces a warning (and = returns an >>> empty string) >>> =C2=A0* $s =3D "string"; =C2=A0$s['1'] -- works as before.. >>> =C2=A0* $s =3D "string"; =C2=A0$s[true] $s[false] $s[0.1] -- give a not= ice (cast it to >>> an int if you want to get rid of the notice) - however work as before. >>> =C2=A0* changes the warning on invalid indexes to say "Uninitialized or >>> invalid" rather than just "Uninitialized" >>> =C2=A0* fixes most of the related tests >>> >> >> I think that those changes are pretty much in line with the discussion t= hat >> we had. >> Thanks for fixing this! >> >> >> -- >> Ferenc Kov=C3=A1cs >> @Tyr43l - http://tyrael.hu > > > > -- > Laruence =C2=A0Xinchen Hui > http://www.laruence.com/ --=20 Laruence =C2=A0Xinchen Hui http://www.laruence.com/