Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116856 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 92332 invoked from network); 10 Jan 2022 17:07:46 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 10 Jan 2022 17:07:46 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9AB76180539; Mon, 10 Jan 2022 10:16:28 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS8560 212.227.0.0/16 X-Spam-Virus: No X-Envelope-From: Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS; Mon, 10 Jan 2022 10:16:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1641838586; bh=Fci+jK5fdjBnCga4HnSI+wDEZMc+/r2lRH9qppw/Tqk=; h=X-UI-Sender-Class:Date:Subject:To:References:Cc:From:In-Reply-To; b=eh8r1PUq0YrT6F9xOcxw6bxwKQ/xdmzpRdXzHNLKJC8cbibfwdgmrDB3ci3ElyXox /S3ojlg3gtS5PH24Xmk5HPlG+iW+zzlTJpRjQx64BN9vxhLSuoSR58rddv9MpuT07W ycUcMGwEydBiUbw5rvkEOdXdSisIvpCvfE/lGc8I= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.2.130] ([79.222.42.193]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MIdiZ-1nAVJP0RaH-00Ee09; Mon, 10 Jan 2022 19:16:26 +0100 Message-ID: <0f503b90-c341-daf7-67a7-ee73598b1a7d@gmx.de> Date: Mon, 10 Jan 2022 19:16:25 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.4.1 Content-Language: de-DE To: Sara Golemon , PHP internals References: Cc: lbarnaud@php.net In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:p+j7P+IeF8X5uIc+Eku40S8AO5kaNJhGnb+IsYSkkRCsl7mvnpt XXnZ8Lbd3LWDQZYEG2pGNHnmxqdswhJ0Ey3HBXd1Vm6vuN19PCsHfkvm5be5FyuUdEWdVlP A8OCojP8noIkWUruje8CVSUu98GrrHvLifpJ5HSwmxlteEswDqeOJ6pXgQ2Wx8l+2eV5IVM F3ZB2ABJRPVj9GLyKIE+g== X-UI-Out-Filterresults: notjunk:1;V03:K0:XKgWn9/tJxM=:L25t2rxExR+RuoJhLKrVOF m13o/nyS12VYY6ZbqOJO+KJoGD7k8pkgS1j6gW06W3w8p1WfM9yYUSB4N20LnfaKnnIRKSvEu yE0C14ovQgQvHcE21HyG5pyNjAGJU4nxUVzmaqgjozGi8VhkVyb+hgWVMPtZKpIeuv72Hyz4D rNQ7LqzK2R8dqp2jhWqJFMMtUP1krhb/XPO04OSsf1RBBCPxTY+O+Hry+dmtHOnNF3ysiVQvs HYfPBekoTtL1ddZKQ3Ap3ApG+Xnag7LPXhBMcddulU+twrr6PcQ2oKVY/MallbzloqCSX0mm3 x0oFOe+eYH9DfOAEfaVYWD12AHpNuy9qWIrlSez7PyOq4NoVKpVYK8IFnwLvrdRtXVK+zzmPP IMxCWAU53yLvap3eJ0Oqa9MmBTCjD6iPEINwkxexRaPe0yu8mIMTKKk7ehPIKeygvW+vCrRWD Xx005DeZrHK9uoNEA3z3zsDk7v5evQxxhmdSn/BFuO77g165su0FdMwIAf0hBdfjYshU6dG5f 2numyb8Im72LfOaNqWLchTVUuKK/j2a5e95tZLCQs8asJUkMaUimizwaXxYAQ2vcKpi7pzmsd GyfimiRwIM/m+IdMfwhPzdr/suvS7EuhJU6A+fmSKeuIuKF4nbXR/HOlv4dT9mHJE9PiCAlRw JBNr0SGgCkkFEfbcvq6r8Eej7F384JCwsEcBuzcRWhKSAVHYKBOfgzmaXYtxUTZoSjEFL1aQI jLBdZ7NNRvTWKlkDKhBig/kh/gjU57zJ+m1DhUtmH/ZDD4zrSlhM3NcTgvFL1Mkb+sWKUpNe6 geO+MR/qkjanMT/lIgtb/LSSwmjeGeVTkVaS5aygXacUuwXb2es/iDkmCiBY06/+PFA+wEWiJ p+UH1snDaOe2rfw3PkGIPy8o+nvrIkjxMkWq4D1vAGTxyEIlIPHVuk2fvddupTPP20ZpPmV0i 44Y5XBJS3bKMDXlWdbYH+FfOE06ZslwpG7bBpSKFOu1rgOdnB0fRyyelGfqCIMaCNnlbMeaTu p5vaVIi/tjnVyyfN+ZRB6RubtNBMxqArrh+YK0LwwRUSZiMXBUlNMNnJpI/FpOuqU8/RDp87l Yy/rVf4dyXedaY= Subject: Re: zend_atol() and zend_atoi() From: cmbecker69@gmx.de ("Christoph M. Becker") On 08.05.2019 at 20:58, Sara Golemon wrote: > I fell down a WTF hole today that led me to zend_atol(). > The end result is the PR which I'd like to present for discussion (I'll = add > tests before I push anything, though it might necessitate a vote). > https://github.com/php/php-src/pull/4132 > > The issue is explained in the commit message, but I'll copy here: > > zend_ato[il] don't just do number parsing. > They also check for a 'K', 'M', or 'G' at the end of the string, > and multiply the parsed value out accordingly. > > Unfortunately, they ignore any other non-numerics between the > numeric component and the last character in the string. > This means that numbers such as the following are both valid > and non-intuitive in their final output. > > - "123KMG" is interpreted as "123G" -> 132070244352 > - "123G " is interpreted as "123 " -> 123 > - "123GB" is interpreted as "123B" -> 123 > - "123 I like tacos." is also interpreted as "123." -> 123 > > This diff primarily adds warnings for these cases when the output > would be a potentially unexpected, and unhelpful value. > > Additionally, several places in php-src use these functions > despite not actually wanting their KMG behavior such as > session.upload_progress.freq which will happily parse "1 banana" > as a valid value. > > For these settings, I've switched them to ZEND_STRTOL which preserves > their existing /intended/ behavior. > > - It won't respect KMG suffixes, but they never really wanted that lo= gic > anyway. > - It will ignore non-numeric suffixes so as to not introduce new > failures. > > We should probably reexamine that second bullet point separately. > > Lastly, with these changes, zend_atoi() is no longer used in php-src, > but I left it as a valid API for 3rd party extensions. > Note that I did make it a proxy to zend_atol() since deferring the > truncation till the end is effectively the same as truncation during > multiplication, but this avoid code duplication. > > I think we should consider removing zend_atoi() entirely (perhaps in 8.0= ?) > and rename zend_atol() to something reflecting it's KMG specific behavio= r. Arnaud Le Blanc grabbed that up, and submitted a while ago. I'm generally in favor of this PR; are there any objections to merging it? Christoph