Commit 26e79288 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

vlc_rand_bytes: minor thread-safety fix

We need the lock to read okey and ikey
parent e80d8803
...@@ -92,19 +92,21 @@ void vlc_rand_bytes (void *buf, size_t len) ...@@ -92,19 +92,21 @@ void vlc_rand_bytes (void *buf, size_t len)
uint64_t val; uint64_t val;
struct md5_s mdi, mdo; struct md5_s mdi, mdo;
InitMD5 (&mdi);
InitMD5 (&mdo);
pthread_mutex_lock (&lock); pthread_mutex_lock (&lock);
if (counter == 0) if (counter == 0)
vlc_rand_init (); vlc_rand_init ();
val = counter++; val = counter++;
pthread_mutex_unlock (&lock);
InitMD5 (&mdi);
AddMD5 (&mdi, ikey, sizeof (ikey)); AddMD5 (&mdi, ikey, sizeof (ikey));
AddMD5 (&mdo, okey, sizeof (okey));
pthread_mutex_unlock (&lock);
AddMD5 (&mdi, &stamp, sizeof (stamp)); AddMD5 (&mdi, &stamp, sizeof (stamp));
AddMD5 (&mdi, &val, sizeof (val)); AddMD5 (&mdi, &val, sizeof (val));
EndMD5 (&mdi); EndMD5 (&mdi);
InitMD5 (&mdo);
AddMD5 (&mdo, okey, sizeof (okey));
AddMD5 (&mdo, mdi.p_digest, sizeof (mdi.p_digest)); AddMD5 (&mdo, mdi.p_digest, sizeof (mdi.p_digest));
EndMD5 (&mdo); EndMD5 (&mdo);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment