php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53403 mt_rand() without min/max uses invalid min/max values
Submitted: 2010-11-25 14:11 UTC Modified: 2010-11-25 17:44 UTC
From: php-bugs at thequod dot de Assigned: cataphract (profile)
Status: Closed Package: Unknown/Other Function
PHP Version: 5.3SVN-2010-11-25 (snap) OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: php-bugs at thequod dot de
New email:
PHP Version: OS:

 

 [2010-11-25 14:11 UTC] php-bugs at thequod dot de
Description:
------------
I am getting the following warning when calling mt_rand() on 5.3.4RC2-dev (snapshot 201011231530), and it returns false:

PHP Warning:  mt_rand(): max(-1080344744) is smaller than min(137322600)


This is on a 32bit Linux container running on a 64bit host (OpenVZ).

Test script:
---------------
var_dump(mt_rand(), mt_getrandmax());

Actual result:
--------------
bool(false)
int(2147483647)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-11-25 14:13 UTC] php-bugs at thequod dot de
The following works btw:
  var_dump(mt_Rand(0, mt_getrandmax()));
 [2010-11-25 14:15 UTC] php-bugs at thequod dot de
-Summary: mr_rand() without min/max uses invalid min/max values +Summary: mt_rand() without min/max uses invalid min/max values
 [2010-11-25 14:15 UTC] php-bugs at thequod dot de
Fixed title.
 [2010-11-25 16:37 UTC] cataphract@php.net
-Assigned To: +Assigned To: cataphract
 [2010-11-25 17:44 UTC] cataphract@php.net
Automatic comment from SVN on behalf of cataphract
Revision: http://svn.php.net/viewvc/?view=revision&revision=305754
Log: - Fixed bug #53403 (use of unitialized values). Fixes the fix for bug #46587.
- Added test for bug #46587.
 [2010-11-25 17:44 UTC] cataphract@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Nov 23 10:01:28 2024 UTC