diff --git a/dhcp.c b/dhcp.c index b8a687a..5fe9112 100644 --- a/dhcp.c +++ b/dhcp.c @@ -358,13 +358,21 @@ static void rfc951_sleep(int exp) static long seed = 0; long q; unsigned long tmo; + + union { + char c[sizeof(gen_hwaddr)]; + long l; + short s[3]; + } hw; if (exp > BACKOFF_LIMIT) exp = BACKOFF_LIMIT; - if (!seed) + if (!seed) { /* Initialize linear congruential generator. */ - seed = (currticks () + *(long *) &gen_hwaddr + ((short *) gen_hwaddr)[2]); + memcpy(&hw.c, &gen_hwaddr, sizeof(gen_hwaddr)); + seed = currticks() + hw.l + hw.s[2]; + } /* Simplified version of the LCG given in Bruce Scheier's "Applied Cryptography". */