...
Code Block | ||
---|---|---|
| ||
int get_secret() { int secret = (rand() % 100) + 100; return secret; } |
Compliant Solution
...
Code Block | ||
---|---|---|
| ||
#include <pthread.h> pthread_mutex_t rand_lock = PTHREAD_MUTEX_INITIALIZER; int get_secret() { int secret; pthread_mutex_lock(&rand_lock) ; secret = (rand() % 100) + 100; pthread_mutex_unlock(&rand_lock); return secret; } |
Risk Assessment
...