Alexander Farber wrote:
Hi,

I'm developing a small multiplayer card game on OpenBSD (but also try to keep it at least compilable on Linux). After 32 cards have been shuffled, each of 3 players gets 10 cards. At the moment I use the sum of time()s when any data has been received from a player as the seed value:

  typedef struct client_s {
      .....
        time_t          last;
  } client;

  .....
  srandom((cp->last + prev->last + next->last) % UINT_MAX);

I'm worried though, that someone will look at my source code
and since those 3 time()s are probably contained in the last 10
minutes, then there aren't actually that many variants.

use arc4random(). If you need to port it to Linux, include an
arc4random() replacement. If you like, you can copy the one from
portable OpenSSH.

-d

Reply via email to