Replaced rand() with random()

pull/5137/head
Rahim Kanji 7 months ago
parent 1e988c665e
commit 9cb605f4fb

@ -1319,10 +1319,8 @@ void PgSQL_Protocol::welcome_client() {
uint32_t backend_pid = (*myds)->sess->thread_session_id;
uint32_t cancel_key = -1;
if (RAND_bytes((unsigned char*)&cancel_key, sizeof(cancel_key)) != 1) {
// Fallback method: using a basic pseudo-random generator
srand((unsigned int)time(NULL));
auto rand_val = rand() % 256;
memcpy(&cancel_key, &rand_val, sizeof(cancel_key));
// Fallback: use libc PRNG
cancel_key = (uint32_t)random();
}
(*myds)->sess->cancel_secret_key = cancel_key;

@ -1460,6 +1460,7 @@ void ProxySQL_Main_init_phase2___not_started(const bootstrap_info_t& boostrap_in
void ProxySQL_Main_init_phase3___start_all() {
srandom((unsigned int)(time(NULL) ^ getpid()));
{
cpu_timer t;
GloMyLogger->events_set_datadir(GloVars.datadir);

Loading…
Cancel
Save