Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d2044c9

Browse files
Move where we generate our salt
Fixes #1987
1 parent 9a3fe40 commit d2044c9

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

redis.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ static const zend_module_dep redis_deps[] = {
129129
};
130130

131131
ZEND_DECLARE_MODULE_GLOBALS(redis)
132-
static PHP_GINIT_FUNCTION(redis);
133132

134133
zend_module_entry redis_module_entry = {
135134
STANDARD_MODULE_HEADER_EX,
@@ -144,7 +143,7 @@ zend_module_entry redis_module_entry = {
144143
PHP_MINFO(redis),
145144
PHP_REDIS_VERSION,
146145
PHP_MODULE_GLOBALS(redis),
147-
PHP_GINIT(redis),
146+
NULL,
148147
NULL,
149148
NULL,
150149
STANDARD_MODULE_PROPERTIES_EX
@@ -425,12 +424,6 @@ static void redis_random_hex_bytes(char *dst, size_t dstsize) {
425424
zend_string_release(s);
426425
}
427426

428-
static PHP_GINIT_FUNCTION(redis)
429-
{
430-
redis_random_hex_bytes(redis_globals->salt, sizeof(redis_globals->salt) - 1);
431-
redis_globals->salt[sizeof(redis_globals->salt)-1] = '\0';
432-
}
433-
434427
/**
435428
* PHP_MINIT_FUNCTION
436429
*/
@@ -442,6 +435,10 @@ PHP_MINIT_FUNCTION(redis)
442435
gettimeofday(&tv, NULL);
443436
srand(tv.tv_usec * tv.tv_sec);
444437

438+
/* Generate our random salt */
439+
redis_random_hex_bytes(REDIS_G(salt), sizeof(REDIS_G(salt)) - 1);
440+
REDIS_G(salt)[sizeof(REDIS_G(salt)) - 1] = '\0';
441+
445442
REGISTER_INI_ENTRIES();
446443

447444
/* Redis class */

0 commit comments

Comments
 (0)