From 34f6f31782d9ea9c2d1d2044b1b2a3f289928ee4 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Wed, 28 Jun 2023 14:50:16 +0200 Subject: [PATCH] use lrand48 instead of lbl_random Custom lbl_random implementation is not properly seeded, when not in Windows, where it is used instead of [ld]rand48. rand48 functions on the other hand are seeded (in host.cpp and rtp.c) so it can be used instead (it perhaps doesn't make much sense to use both implementation in UltraGrid except Windows, where custom implementation is used solely). lbl_[s]random remains used in crypto_des (which is, however, not used). --- src/rtp/rtp.c | 4 ++-- src/tv.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/rtp/rtp.c b/src/rtp/rtp.c index 97cc17278b..ca5ad01b2a 100644 --- a/src/rtp/rtp.c +++ b/src/rtp/rtp.c @@ -3333,7 +3333,7 @@ static void send_rtcp(struct rtp *session, uint32_t rtp_ts, check_database(session); /* If encryption is enabled, add a 32 bit random prefix to the packet */ if (session->encryption_enabled) { - *((uint32_t *)(void *) ptr) = lbl_random(); + *((uint32_t *)(void *) ptr) = lrand48(); ptr += 4; } @@ -3571,7 +3571,7 @@ static void rtp_send_bye_now(struct rtp *session) check_database(session); /* If encryption is enabled, add a 32 bit random prefix to the packet */ if (session->encryption_enabled) { - *((uint32_t *)(void *) ptr) = lbl_random(); + *((uint32_t *)(void *) ptr) = lrand48(); ptr += 4; } diff --git a/src/tv.c b/src/tv.c index 4dd98210a1..a908e17d82 100644 --- a/src/tv.c +++ b/src/tv.c @@ -61,7 +61,7 @@ uint32_t get_local_mediatime(void) if (first == 0) { gettimeofday(&start_time, NULL); - random_offset = lbl_random(); + random_offset = lrand48(); first = 1; } @@ -181,7 +181,7 @@ uint32_t get_std_audio_local_mediatime(double samples, int rate) gettimeofday(&standard_time.start_time, NULL); standard_time.atime = standard_time.start_time; standard_time.vtime = standard_time.start_time; - standard_time.random_startime_offset = lbl_random(); + standard_time.random_startime_offset = lrand48(); tv_add_usec(&standard_time.vtime, standard_time.random_startime_offset); tv_add_usec(&standard_time.atime, standard_time.random_startime_offset); @@ -207,7 +207,7 @@ uint32_t get_std_video_local_mediatime(void) gettimeofday(&t0, NULL); standard_time.atime = standard_time.start_time; standard_time.vtime = standard_time.start_time; - standard_time.random_startime_offset = lbl_random(); + standard_time.random_startime_offset = lrand48(); tv_add_usec(&standard_time.vtime, standard_time.random_startime_offset); tv_add_usec(&standard_time.atime, standard_time.random_startime_offset);