]> git.pld-linux.org Git - packages/php-pecl-solr.git/blame - do-not-screw-with-random-seed.patch
fix extension version
[packages/php-pecl-solr.git] / do-not-screw-with-random-seed.patch
CommitLineData
d0d88926
ER
1DO NOT SCREW WITH RANDOM SEED
2
3Do not initialize the seed with srand or mt_srand, it is already initialized
4since PHP 4.2.0 (See the docs). And if you initialize it with time or microtime
5you make it only more worse (predictable).
6
7And initializing random seed with predictable value is extremely stupid.
8
9I had situation that three machines simulatenously produced temporary directory
10names based on random generator, and they all got same results, this is utterly
11screwed up up the application!
12
13Jul 6 10:37:26 segusilm php.fcgi: PHP Fatal error: Uncaught exception 'Exception' with message 'Can't mkdir '/tmp/foo_UZNHCMUDWZ/archive': mkdir(): File exists' in /usr/share/foo/lib/plugins/Plugin.php:127
14Jul 6 10:37:26 lordi php.fcgi: PHP Warning: unlink(/tmp/foo_UZNHCMUDWZ/archive/title.inc): No such file or directory in /usr/share/foo/lib/helper/OutputHelper.php on line 68
15
16it is strongly recommended for PHP application developers to keep their fingers
17away from srand() or mt_srand() and to never ever use rand() or mt_rand() for
18cryptographic secrets:
19http://www.suspekt.org/2008/08/17/mt_srand-and-not-so-random-numbers/
20
679c5dc2
ER
21Bugreport: https://bugs.php.net/bug.php?id=62835
22Source: http://cvs.pld-linux.org/packages/php-pecl-solr/do-not-screw-with-random-seed.patch
23Signed-Off-By: Elan Ruusamäe <glen@pld-linux.org>
24Tested-By: Elan Ruusamäe <glen@delfi.ee>
d0d88926
ER
25--- php-pecl-solr-1.0.2/php_solr.c~ 2011-11-29 04:50:07.000000000 +0200
26+++ php-pecl-solr-1.0.2/php_solr.c 2012-07-06 18:15:25.730180032 +0300
27@@ -1082,9 +1082,6 @@
28 /* Always NULL. Kept for API backward compatibility purposes only */
29 hash_func_t pHashFunction = NULL;
30
31- /* initialize random seed */
32- srand(time(NULL));
33-
34 ALLOC_HASHTABLE(SOLR_GLOBAL(documents));
35 ALLOC_HASHTABLE(SOLR_GLOBAL(clients));
36 ALLOC_HASHTABLE(SOLR_GLOBAL(params));
This page took 0.062237 seconds and 4 git commands to generate.