svn commit: r301298 - stable/10/sys/compat/ndis

Pedro F. Giffuni pfg at FreeBSD.org
Sat Jun 4 04:01:29 UTC 2016


Author: pfg
Date: Sat Jun  4 04:01:28 2016
New Revision: 301298
URL: https://svnweb.freebsd.org/changeset/base/301298

Log:
  MFC r300376:
  ndis(4): Better mimic the behavior of rand() on Windows.
  
  In ndis(4) we expose a rand() function that was constantly reseeding
  with a time depending function every time it was called. This
  essentially broke the reasoning behind seeding, and rendered srand()
  a no-op.
  
  Keep it simple, just use random() and srandom() as it's meant to work.
  It would have been tempting to just go for arc4random() but we
  want to mimic Microsoft, and we don't need crypto-grade randomness
  here.
  
  PR:		209616

Modified:
  stable/10/sys/compat/ndis/subr_ntoskrnl.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/compat/ndis/subr_ntoskrnl.c
==============================================================================
--- stable/10/sys/compat/ndis/subr_ntoskrnl.c	Sat Jun  4 03:54:30 2016	(r301297)
+++ stable/10/sys/compat/ndis/subr_ntoskrnl.c	Sat Jun  4 04:01:28 2016	(r301298)
@@ -3188,17 +3188,14 @@ atol(str)
 static int
 rand(void)
 {
-	struct timeval		tv;
 
-	microtime(&tv);
-	srandom(tv.tv_usec);
-	return ((int)random());
+	return (random());
 }
 
 static void
-srand(seed)
-	unsigned int		seed;
+srand(unsigned int seed)
 {
+
 	srandom(seed);
 }
 


More information about the svn-src-all mailing list