From 870637418940a74eeb804e44f3ad62330169abf3 Mon Sep 17 00:00:00 2001 From: "Andrey A. Chernov" Date: Sun, 11 May 1997 00:16:00 +0000 Subject: [PATCH] Use random() for GenerateMagic() --- usr.sbin/ppp/lcp.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/usr.sbin/ppp/lcp.c b/usr.sbin/ppp/lcp.c index 4bc0ebf49140..4eede6ad5e8b 100644 --- a/usr.sbin/ppp/lcp.c +++ b/usr.sbin/ppp/lcp.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: lcp.c,v 1.14 1997/05/05 23:45:15 brian Exp $ + * $Id: lcp.c,v 1.15 1997/05/10 01:22:13 brian Exp $ * * TODO: * o Validate magic number received from peer. @@ -47,6 +47,7 @@ extern void StopIdleTimer(); extern void OsLinkdown(); extern void Cleanup(); extern struct pppTimer IpcpReportTimer; +extern int randinit; struct lcpstate LcpInfo; @@ -179,14 +180,13 @@ ReportLcpStatus() u_long GenerateMagic() { - time_t tl; - struct timeval tval; + if (!randinit) { + randinit = 1; + if (srandomdev() < 0) + srandom((unsigned long)(time(NULL) ^ getpid())); + } - time(&tl); - gettimeofday(&tval, NULL); - tl += (tval.tv_sec ^ tval.tv_usec) + getppid(); - tl *= getpid(); - return(tl); + return (random()); } void