summaryrefslogtreecommitdiff
path: root/ext/standard/rand.c
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2010-11-23 13:09:15 +0000
committerIlia Alshanetsky <iliaa@php.net>2010-11-23 13:09:15 +0000
commit09b69ee8ade5ab5235aca17cb9e9e1202f3aba87 (patch)
tree43902bab6d97fee77905168875ba41463b65e285 /ext/standard/rand.c
parentf93b470fd4b445de6a8446e270bd2f70e4cd7353 (diff)
downloadphp-git-09b69ee8ade5ab5235aca17cb9e9e1202f3aba87.tar.gz
Fixed bug #46587 (mt_rand() does not check that max is greater than min).
Diffstat (limited to 'ext/standard/rand.c')
-rw-r--r--ext/standard/rand.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/ext/standard/rand.c b/ext/standard/rand.c
index 4f1f18b278..eb26cc5c50 100644
--- a/ext/standard/rand.c
+++ b/ext/standard/rand.c
@@ -322,6 +322,11 @@ PHP_FUNCTION(mt_rand)
php_mt_srand(GENERATE_SEED() TSRMLS_CC);
}
+ if (max < min) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "max(%d) is smaller than min(%d)", max, min);
+ RETURN_FALSE;
+ }
+
/*
* Melo: hmms.. randomMT() returns 32 random bits...
* Yet, the previous php_rand only returns 31 at most.