Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
71da1b15
Commit
71da1b15
authored
Jan 22, 2015
by
antirez
Browse files
The seed must be static in getRandomHexChars().
parent
4e73b305
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/util.c
View file @
71da1b15
...
@@ -431,10 +431,10 @@ int d2string(char *buf, size_t len, double value) {
...
@@ -431,10 +431,10 @@ int d2string(char *buf, size_t len, double value) {
void
getRandomHexChars
(
char
*
p
,
unsigned
int
len
)
{
void
getRandomHexChars
(
char
*
p
,
unsigned
int
len
)
{
char
*
charset
=
"0123456789abcdef"
;
char
*
charset
=
"0123456789abcdef"
;
unsigned
int
j
;
unsigned
int
j
;
unsigned
char
seed
[
20
];
/* A seed to have a different sequence each run. */
/* Global state. */
/* Global state. */
static
int
seed_initialized
=
0
;
static
int
seed_initialized
=
0
;
static
unsigned
char
seed
[
20
];
/* The SHA1 seed, from /dev/urandom. */
static
uint64_t
counter
=
0
;
/* The counter we hash with the seed. */
static
uint64_t
counter
=
0
;
/* The counter we hash with the seed. */
if
(
!
seed_initialized
)
{
if
(
!
seed_initialized
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment