httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ben Laurie <...@algroup.co.uk>
Subject Re: cvs commit: apache-1.3/src/modules/standard mod_rewrite.h
Date Wed, 04 Mar 1998 18:17:51 GMT
Ralf S. Engelschall wrote:
> 
> rse         98/03/03 07:53:34
> 
>   Modified:    src/modules/standard mod_rewrite.h
>   Log:
>   Add own definition for RAND_MAX because some non-strict-POSIX
>   platforms don't define it although they provide the rand() function :-(

If you are going to do this, you'll need to make sure rand() doesn't
screw you up by giving you something bigger than RAND_MAX. I'd suggest
you change this:

   sprintf(buf, "%.0f", (((double)rand()/RAND_MAX)*(h-l)));
 
to this:

   sprintf(buf, "%.0f",
(((double)(rand()%(RAND_MAX+1))/RAND_MAX)*(h-l)));

Hmmm... unfortunately, if RAND_MAX is 2^32-1, then this'll overflow. But
you get my drift!

Cheers,

Ben.

-- 
Ben Laurie            |Phone: +44 (181) 735 0686|  Apache Group member
Freelance Consultant  |Fax:   +44 (181) 735 0689|http://www.apache.org
and Technical Director|Email: ben@algroup.co.uk |
A.L. Digital Ltd,     |Apache-SSL author    http://www.apache-ssl.org/
London, England.      |"Apache: TDG" http://www.ora.com/catalog/apache

Mime
View raw message