Skip to content

Commit

Permalink
use lrand48 instead of lbl_random
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
MartinPulec committed Jun 28, 2023
1 parent e32f116 commit 34f6f31
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/rtp/rtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down
6 changes: 3 additions & 3 deletions src/tv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);

Expand All @@ -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);

Expand Down

0 comments on commit 34f6f31

Please sign in to comment.