Bug #69803 [Asn->Csd]: gmp_random_range() modifies second parameter if GMP number
| From: | nikic@php.net | Date: | Thu, 11 Jun 2015 20:21:37 +0000 |
| Subject: | Bug #69803 [Asn->Csd]: gmp_random_range() modifies second parameter if GMP number | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-193340@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=69803&edit=1
ID: 69803
Updated by: nikic@php.net
Reported by: andy dot shawaluk at pkware dot com
Summary: gmp_random_range() modifies second parameter if GMP
number
-Status: Assigned
+Status: Closed
Type: Bug
Package: GNU MP related
Operating System: Windows 7
PHP Version: master-Git-2015-06-11 (snap)
Assigned To: nikic
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of nikic
Revision: http://git.php.net/?p=php-src.git;a=commit;h=1acf55eb752db482509d2f9c48443466f9a1bf68
Log: Fixed bug #69803
Previous Comments:
------------------------------------------------------------------------
[2015-06-11 19:47:56] nikic@php.net
Also applies to 5.6: http://3v4l.org/ndepv
------------------------------------------------------------------------
[2015-06-11 19:38:49] andy dot shawaluk at pkware dot com
Description:
------------
When calling the gmp_random_range($min,$max) function where $max is a GMP number, the value of $max
is modified - after the function returns, it is reduced by ($min-1).
If $max is an ordinary integer (as shown in the online help page), this does not happen.
Tested with latest Windows Master snapshot (VC11 x86 Thread Safe), retrieved from http://windows.php.net/snapshots/ on 2015/06/11 14:34
CDT.
Revision: r7ec3016 (June 09 2015, 17:20:07)
Test script:
---------------
<?php
$a = gmp_init('100'); $b = gmp_init('200');
echo gmp_strval($a) .", ". gmp_strval($b) ."\n";
$c = gmp_random_range($a, $b);
echo gmp_strval($a) .", ". gmp_strval($b) ." -> ". gmp_strval($c)
."\n";
Expected result:
----------------
100, 200
100, 200 -> [number between 100 and 200 inclusive]
Actual result:
--------------
100, 200
100, 101 -> [number between 100 and 200 inclusive]
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=69803&edit=1