Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101986 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 98908 invoked from network); 18 Mar 2018 22:55:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Mar 2018 22:55:45 -0000 Authentication-Results: pb1.pair.com smtp.mail=smalyshev@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=smalyshev@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.160.44 as permitted sender) X-PHP-List-Original-Sender: smalyshev@gmail.com X-Host-Fingerprint: 209.85.160.44 mail-pl0-f44.google.com Received: from [209.85.160.44] ([209.85.160.44:35642] helo=mail-pl0-f44.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9C/7B-15530-07EEEAA5 for ; Sun, 18 Mar 2018 17:55:44 -0500 Received: by mail-pl0-f44.google.com with SMTP id p9-v6so6568569pls.2 for ; Sun, 18 Mar 2018 15:55:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=LoBSCUdOEaoLOE0Mb1Z2vujnangtCWDO8v2yzYxTPcw=; b=dcUw4euT0h1qjsJRjV8Weux3JIDOmjuiCmmKW7Shpy7LI7XbLbZGVfav2Ef6GFSujt Q6AYNwczywHqqOv2AyJGQwQu1HcYkF+4bQrEXbAQun07AaxNEOD2q50nsF2SvYpC7cMF fgbikmaT7GWd8CSZ3vbl5aY6VsjbHFG2488Y1aFmZWa7itZDrgiG0xFpcylu+mgnNTdX t8Kd/gA3R9JYl+AixhYgtdkXawWhAtNAK7X2A6eIyoJY4tYzpZhdrg9huznFuSwTMnr8 PXHLHiAjvB/oS9vYzaJKZBLvzqUlPXqalV4umiDuen4AKU+Jg6ttNxS4O/e7LsGYwgs1 iapQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=LoBSCUdOEaoLOE0Mb1Z2vujnangtCWDO8v2yzYxTPcw=; b=Y6Zvl65cYP47Mz4Kjs0NfMLzpN6PeM/SdTWMAFyrc3AAeK/bMiQ/eosbeWpA8cS4y7 A/+VjaMQR+0Oqt/9gSRTykfgWyCzBdDOUoMYB3fO25ip9mqTNAf85BqheXS5x/P7cJ6q bMvu4V6V1QRcAysmXvMST3UXTKMZvw05pNClci+SuhplOiTb68z6SUkW2snuSJNduLtx x853+AXv8iQEeYdPMVomwLkfd+mpiAbS8V3RXngCmNd6dd4Kjtxac5C2sNpm9iNTW+4h JqVBSmBX7Pn5K4DtbpcFOmgDCc4HY88PHoR3PBhh5pxybc0UAv5ZiCH+9FAqisVmpz3k SQ+Q== X-Gm-Message-State: AElRT7FcyUkq91FWThzR0mX/WtIiZkl3DJxEL4OJ0mljRYLpC/kBcOnn AMoW9jhUHk+cY40vgg1j+EpBiAc= X-Google-Smtp-Source: AG47ELvUoYwC6qfPvGvzWgDsPwICp86m4i8M/oF2FmDhI+j9H0BLIPCJjynBqhgD5XPXem5kBQ+v4g== X-Received: by 2002:a17:902:6b0c:: with SMTP id o12-v6mr10417969plk.295.1521413741029; Sun, 18 Mar 2018 15:55:41 -0700 (PDT) Received: from Stas-Pro-2016.local (c-73-71-144-171.hsd1.ca.comcast.net. [73.71.144.171]) by smtp.gmail.com with ESMTPSA id t28sm27562945pfk.138.2018.03.18.15.55.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Mar 2018 15:55:40 -0700 (PDT) To: Sara Golemon Cc: "Christoph M. Becker" , PHP internals References: <1e29d1b7-dbf4-35d5-61cc-8348c195984a@gmx.de> <1a373841-649b-aef0-1eea-637980463bbd@gmail.com> Message-ID: Date: Sun, 18 Mar 2018 15:55:39 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:59.0) Gecko/20100101 Thunderbird/59.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Re: [RFC] Base Conversion Clowniness From: smalyshev@gmail.com (Stanislav Malyshev) Hi! > Technically, the internal API as it stands *can* return FAILURE > already, though I can see your argument that a caller might assume > that it'll never fail so long as they pass a string with a valid base. > I don't think I agree with your point, as it's reasonable to expect an > API caller to examine the return code of the function they're > calling,. but I can see where you're coming from. The problem is that if we return false, and the caller expects a number, it may use the zval as numeric zval without conversion. I am not sure in 7.x using false as IS_LONG without conversion is safe anymore, but it is possible that with proper initialization it would be. Other scenarios - such as throwing without initializing the zval - may behave even worse. Option C is relatively safe I think. Maybe B is safe too, and D can be made safe with proper initialization - in any case that needs to be checked. > it's reasonable to expect an API caller to examine the return code of the function they're > calling We aren't really good in documenting when API functions return SUCCESS/FAILURE. In this particular case, the source indicates that if you send it a string and the base is constant (common case), it would never return FAILURE. So it's hard to blame extension writer who would not check for FAILURE. If we're changing the contract (or rather, having failed to document any explicit contract, changing the implied contract defined by the source code) we need at least to take some measures so that we don't create subtle bugs in other extensions. Fortunately, in this case it seems to be achievable. -- Stas Malyshev smalyshev@gmail.com