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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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: Thu Nov 21 14:01:29 2024 UTC