Mercurial > dovecot > core-2.2
view src/lib/rand.c @ 23007:36e01285b5b8
lib: buffer - Improve header comment for buffer_insert() and buffer_delete().
author | Stephan Bosch <stephan.bosch@dovecot.fi> |
---|---|
date | Mon, 18 Mar 2019 00:52:37 +0100 |
parents | cb108f786fb4 |
children |
line wrap: on
line source
/* Copyright (c) 2014-2018 Dovecot authors, see the included COPYING file */ /* Wrap srand() so that we can reproduce fuzzed tests */ #include "lib.h" static int seeded = 0; static unsigned int seed; static char const *env_seed; int rand_get_seed_count(void) { return seeded; } unsigned int rand_get_last_seed(void) { i_assert(seeded > 0); return seed; } void rand_set_seed(unsigned int s) { if (seeded == 0) { unsigned int seedval; env_seed = getenv("DOVECOT_SRAND"); if (env_seed != NULL && str_to_uint(env_seed, &seedval) >= 0) seed = seedval; } seeded++; if (env_seed == NULL) seed = s; srand(seed); }