Bug #69803 [NEW]: gmp_random_range() modifies second parameter if GMP number
| From: | andy dot shawaluk at pkware dot com | Date: | Thu, 11 Jun 2015 19:38:50 +0000 |
| Subject: | Bug #69803 [NEW]: gmp_random_range() modifies second parameter if GMP number | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-193338@lists.php.net to get a copy of this message | ||
From: andy dot shawaluk at pkware dot com
Operating system: Windows 7
PHP version: master-Git-2015-06-11 (snap)
Package: GNU MP related
Bug Type: Bug
Bug description:gmp_random_range() modifies second parameter if GMP number
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 bug report at https://bugs.php.net/bug.php?id=69803&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69803&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69803&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69803&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=69803&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=69803&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=69803&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=69803&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=69803&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=69803&r=support
Expected behavior: https://bugs.php.net/fix.php?id=69803&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=69803&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=69803&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=69803&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69803&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=69803&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=69803&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=69803&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69803&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=69803&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=69803&r=mysqlcfg