cvs: php3 /functions rand.c
| From: | Martin Kraemer | Date: | Thu, 27 Jun 2002 14:01:38 +0000 |
| Subject: | cvs: php3 /functions rand.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-12577@lists.php.net to get a copy of this message | ||
martin Thu Jun 27 10:01:38 2002 EDT
Modified files:
/php3/functions rand.c
Log:
For rand($lo,$hi), compare $hi against the actual value of PHP_RAND_MAX
as used in the (lo,hi) calculation and also as returned by getrandmax(),
and not against RAND_MAX == 0x8000.
Error reported by Oliver Reh <Oliver.Reh at FAEDV-N.Bayern.de>
Index: php3/functions/rand.c
diff -u php3/functions/rand.c:1.39 php3/functions/rand.c:1.40
--- php3/functions/rand.c:1.39 Mon May 22 13:31:41 2000
+++ php3/functions/rand.c Thu Jun 27 10:01:37 2002
@@ -30,7 +30,7 @@
| Based on code from: Shawn Cokus <Cokus@math.washington.edu> |
+----------------------------------------------------------------------+
*/
-/* $Id: rand.c,v 1.39 2000/05/22 17:31:41 hholzgra Exp $ */
+/* $Id: rand.c,v 1.40 2002/06/27 14:01:37 martin Exp $ */
#include <stdlib.h>
@@ -267,7 +267,7 @@
convert_to_long(p_max);
if (p_max->value.lval-p_min->value.lval <= 0) {
php3_error(E_WARNING,"rand(): Invalid range: %ld..%ld", p_min->value.lval,
p_max->value.lval);
- } else if (p_max->value.lval-p_min->value.lval > RAND_MAX){
+ } else if (p_max->value.lval-p_min->value.lval > PHP_RAND_MAX){
php3_error(E_WARNING,"rand(): Invalid range: %ld..%ld", p_min->value.lval,
p_max->value.lval);
}
break;