Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:76902 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 179 invoked from network); 27 Aug 2014 07:55:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Aug 2014 07:55:01 -0000 Authentication-Results: pb1.pair.com smtp.mail=pierre.php@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=pierre.php@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.51 as permitted sender) X-PHP-List-Original-Sender: pierre.php@gmail.com X-Host-Fingerprint: 209.85.216.51 mail-qa0-f51.google.com Received: from [209.85.216.51] ([209.85.216.51:58639] helo=mail-qa0-f51.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C5/52-20444-4DE8DF35 for ; Wed, 27 Aug 2014 03:55:00 -0400 Received: by mail-qa0-f51.google.com with SMTP id k15so14650156qaq.38 for ; Wed, 27 Aug 2014 00:54:57 -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=r/MyL3zKb+7ECMidSMcX0t72VcNETDu5RkFQy2TrSOM=; b=LpddQlvx45EtbDUEtxzgeSmryeEtTSBLdfcWvyneMlMD747ZemIdC2LcAjv9VFKi6Y vmWv4oeMVqY5BjwHKlRiPSZSv5/MpVDU3QiF1v+z1ahRqcman1lm5owmODoVwSbgdWsN x9CRbttNSUtCbjODqDAvcAIuNPZZnk3oEjD5ieHH+jyX25aBI9HfErzImefTFwt94jwW DBL70w71MYec9qLZVQMcQK7g0yK6OtXF3C4gzYcLzv74L6Fhqr2A7L5AQoNcjMEbLOuw ICJEz3VTQLudgmuj/H5eDKr6wsu9K6cKzaN6D15UXP0dk6T+nf1EiVJScWq4EAO9/DG5 9aSg== MIME-Version: 1.0 X-Received: by 10.140.85.135 with SMTP id n7mr49741688qgd.22.1409126097694; Wed, 27 Aug 2014 00:54:57 -0700 (PDT) Received: by 10.140.95.146 with HTTP; Wed, 27 Aug 2014 00:54:57 -0700 (PDT) In-Reply-To: <221c660eb11d0f30bb065bbc34e657f4.squirrel@webmail.klapt.com> References: <62188C5D-C62B-493F-8CB1-9B48C5555131@gmail.com> <221c660eb11d0f30bb065bbc34e657f4.squirrel@webmail.klapt.com> Date: Wed, 27 Aug 2014 09:54:57 +0200 Message-ID: To: Anatol Belski Cc: Tjerk Meesters , PHP Internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Re: zpp and zend_string From: pierre.php@gmail.com (Pierre Joye) On Wed, Aug 27, 2014 at 8:51 AM, Anatol Belski wrote: > Hi Tjerk, > > On Wed, August 27, 2014 07:34, Tjerk Meesters wrote: >> Hi internals, >> >> >> With the recent merge of int64 the `zend_string` type now uses `size_t` >> to store its length, but ZPP (and friends) still use `int *` to store the >> parsed string lengths. >> >> http://lxr.php.net/xref/PHP_TRUNK/Zend/zend_API.c#519 >> >> > Yep, this is a good question, as that zend_string uses size_t for the > length now with 'S', but 's' goes the old way. IMHO we should let it be as > it is, or even enforce 's' length to be exact unsigned 32 bit. And, we > should check for places where we need the conversion to zend_string - > those are > > - where we work with pure strings in PHP, like substr() for example > - where the dependency library requieres or supports that > > As example - it makes no sense to use zend_string for zlib or ICU, but > it's fulle justified for iconv. That's not related to zend_string usage or not but the length of the string. One function would be safe or allow large string and other not? That does not sound good. F.e. ICU uses int32_t, zlib uses uLong (custom type defined to unsigned long). For ICU, a overflow check is required before calling. For zlib, it depends on the size of size_t, but ulong can then be 64bit (as zlib supports large buffer compression). It does not mean zlib will have large buffer in memory (stream compression f.e.) but it has to be able to return the size of the in or out. We have to use size_t here. We have to deal with large string as the zpp level, or it will be a total mess if some functions accept it and other not. Just like what we already do with similar issues, size checks are necessary before calling an external API, raising an error/failing if the given buffer is too large for a given external function. Cheers, -- Pierre @pierrejoye | http://www.libgd.org