Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87892 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 34277 invoked from network); 24 Aug 2015 14:06:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Aug 2015 14:06:04 -0000 Authentication-Results: pb1.pair.com header.from=theanomaly.is@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=theanomaly.is@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.43 as permitted sender) X-PHP-List-Original-Sender: theanomaly.is@gmail.com X-Host-Fingerprint: 209.85.215.43 mail-la0-f43.google.com Received: from [209.85.215.43] ([209.85.215.43:35250] helo=mail-la0-f43.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 58/93-32838-BC42BD55 for ; Mon, 24 Aug 2015 10:06:04 -0400 Received: by labgv11 with SMTP id gv11so10406266lab.2 for ; Mon, 24 Aug 2015 07:06:00 -0700 (PDT) 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=LFYaFEiSsTJZaZdZ/YycznV5tzBhnw+6tTWiYHJbdOc=; b=0MRTS1ltq7/emX6TH3vU0tdH67Y0CC2gbI/d4EPgIBr7uja1kB5wddRnRK0+8THa39 4HpDz5wTqDW7LibETy/7SKRT0XzXX6ZBTQqUhk6HHythadj30ZkQsosCmOhHQTWrMhMr 3PnM+fLCwXvZ8ZKRhQqke1InvV7LtvwRIh6SCwY9K4qWyx2KCmoqlwLpTR32A0BgfXto qgv08j+cSQupzXYXuLdC2ZXT9xuu9o2K70kCtcFu1OCpgOkqeTsdKnoOsLkR05OZc4Ae Q8lRQSftRN2iH3kdYZslrL6pAUqQtG/QNOnglQQIwt2+3WcpJZIX1q+wfLlUsecazRCx moQw== MIME-Version: 1.0 X-Received: by 10.152.170.130 with SMTP id am2mr20585768lac.54.1440425160552; Mon, 24 Aug 2015 07:06:00 -0700 (PDT) Received: by 10.25.200.196 with HTTP; Mon, 24 Aug 2015 07:06:00 -0700 (PDT) In-Reply-To: <55DA4924.2060401@gmail.com> References: <02a601d0dbed$2c828df0$8587a9d0$@belski.net> <02ae01d0dbf5$01c17330$05445990$@belski.net> <02b001d0dbf5$607ab7b0$21702710$@belski.net> <02ba01d0dbfb$3de2c390$b9a84ab0$@belski.net> <55DA4924.2060401@gmail.com> Date: Mon, 24 Aug 2015 10:06:00 -0400 Message-ID: To: Rowan Collins Cc: PHP Internals Content-Type: multipart/alternative; boundary=089e01161568053a34051e0f1e4a Subject: Re: [PHP-DEV] Overflow checks and integral vars comparison From: theanomaly.is@gmail.com (Sherif Ramadan) --089e01161568053a34051e0f1e4a Content-Type: text/plain; charset=UTF-8 Hey Rowan, Yup, I get it now. Sorry for the confusion. I actually remember fixing a similar bug in pdo_sqlite a while back where casting/translation between the two sizes caused such an issue. So I think this would be pretty helpful. On Sun, Aug 23, 2015 at 6:28 PM, Rowan Collins wrote: > 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] > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --089e01161568053a34051e0f1e4a--