Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87885 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 65627 invoked from network); 23 Aug 2015 22:28:57 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Aug 2015 22:28:57 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.179 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.212.179 mail-wi0-f179.google.com Received: from [209.85.212.179] ([209.85.212.179:38405] helo=mail-wi0-f179.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F0/90-59327-8294AD55 for ; Sun, 23 Aug 2015 18:28:57 -0400 Received: by wicja10 with SMTP id ja10so56754185wic.1 for ; Sun, 23 Aug 2015 15:28:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-type:content-transfer-encoding; bh=HWYSVcsiHeMFHOSrUYg+wP+9dU3Gyka0FBc990VndrY=; b=ka67FdRnzpfc7Azm+ERl9r60wlHl6/7pLbnCE8xyJehrBpTnaCZHdnkp/jxvKyejEh twsfwiTC8cKK4LiS9kEuE9X+gzc4Fh+xqnuCC4LKO6B1bRxFA9CgrWy2YxufRpWtjNiC 621AaVloYaXFb10PZ/WBOdlEzQjFUtv9d74OC7iEfcOXM6abhUGq+Z7BXl3HygBvkI/2 8YRXH0/RcbAWjG9Y3+YkRjWPw+bz4EwUYiVv/tUHPZgQzXE3z5SZjwuZ4zKxVkraAEXo W4VpCIG+TpQRqvDtMK3hiqMEIyBi6u2r6bA4QlFtYC/Pb2IddwECeqagzVzL099yj3FC y79g== X-Received: by 10.180.88.98 with SMTP id bf2mr13736078wib.90.1440368933602; Sun, 23 Aug 2015 15:28:53 -0700 (PDT) Received: from [192.168.0.5] (cpc68956-brig15-2-0-cust215.3-3.cable.virginm.net. [82.6.24.216]) by smtp.googlemail.com with ESMTPSA id ne7sm9579594wic.12.2015.08.23.15.28.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 23 Aug 2015 15:28:52 -0700 (PDT) To: internals@lists.php.net References: <02a601d0dbed$2c828df0$8587a9d0$@belski.net> <02ae01d0dbf5$01c17330$05445990$@belski.net> <02b001d0dbf5$607ab7b0$21702710$@belski.net> <02ba01d0dbfb$3de2c390$b9a84ab0$@belski.net> Message-ID: <55DA4924.2060401@gmail.com> Date: Sun, 23 Aug 2015 23:28:52 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Overflow checks and integral vars comparison From: rowan.collins@gmail.com (Rowan Collins) On 22/08/2015 02:38, Sherif Ramadan wrote: > I see. So you're not actually doing overflow checks then? Because at the > point you'd be checking this zend_long or size_t it could have already > overflowed or wrapped. The subject may have misled me to understand > differently. I think I understand the confusion: you are thinking of overflow as something which happens *within* a type based on some operation (addition, multiplication, etc). Anatol is talking about overflows which occur when casting *between* types: a value of 2^33 can safely be passed around as a 64-bit integer, no overflow has occurred; but attempting to cast it to a 32-bit integer will immediately overflow the 32-bit integer. Since many PHP extensions are wrappers around libraries which may only deal in 32-bit types, this cast is common, necessitating range checks like the ones proposed. Regards, -- Rowan Collins [IMSoP]