Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87070 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 26081 invoked from network); 8 Jul 2015 10:03:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Jul 2015 10:03:41 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.46 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 74.125.82.46 mail-wg0-f46.google.com Received: from [74.125.82.46] ([74.125.82.46:36851] helo=mail-wg0-f46.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2B/D3-16503-B75FC955 for ; Wed, 08 Jul 2015 06:03:40 -0400 Received: by wgxm20 with SMTP id m20so7728237wgx.3 for ; Wed, 08 Jul 2015 03:03:37 -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=7Y3vSELUgyrkzqrzNGCPEeshunE+6Pt3HRyy5oV2HiI=; b=SmHBNSz1KyURrZIkiBChJPrswB/tMmRBn2qsmaDGKAmToUFhoh9GN0FA4cujNY/gXW H294cg+zbgXn7VFoQ9mwwC5I33tmA0NNfoV2m3V98s2Bn6iECwGbidXs75Of8UXySYhy VNZH+JRyJ2vZGTwMmv4UbwMql/jKhujhspm/hE5JnQWos/zLghe6DBJbyZtsRulBcb2G 5aumZB101KL7GUlOEY7XCnA3ElbPH6IutqMSLVaHXzqAx8KFZjFAFbKu45nSFK2WrLXT V6ahXvMn4c143iFr1b7CAVAxh03ABtFgdOP1T1B4gNIsudD6oqskwVye+/m4BQ1MvEBB QrGw== MIME-Version: 1.0 X-Received: by 10.180.228.6 with SMTP id se6mr107314709wic.33.1436349817046; Wed, 08 Jul 2015 03:03:37 -0700 (PDT) Received: by 10.27.79.200 with HTTP; Wed, 8 Jul 2015 03:03:36 -0700 (PDT) In-Reply-To: References: Date: Wed, 8 Jul 2015 12:03:36 +0200 Message-ID: To: Scott Arciszewski Cc: PHP Internals Content-Type: multipart/alternative; boundary=001a1135e3989e5380051a5a4069 Subject: Re: [PHP-DEV] random_compat From: nikita.ppv@gmail.com (Nikita Popov) --001a1135e3989e5380051a5a4069 Content-Type: text/plain; charset=UTF-8 On Wed, Jul 8, 2015 at 11:59 AM, Scott Arciszewski wrote: > Hi everyone, > > I'm working on a library to backport random_bytes() and random_int() > into PHP 5. The effort is located on Github if anyone is interested: > https://github.com/paragonie/random_compat > > My reason for this email is that I'm running into one compatibility > issue that I don't think I can safely work around: If we let > random_int() default to -PHP_INT_MAX and PHP_INT_MAX, then the > difference between the two (used to calculate the range) will overflow > into a float, which will lead to a loss of precision. > > My current compromise is to use -(PHP_INT_MAX/2) and PHP_INT_MAX/2, > but I'm not sure if there's a better solution. > random_int() arguments don't have default values, you have to explicitly pass both. (Of course you still have a problem if someone does pass them :) Nikita --001a1135e3989e5380051a5a4069--