From owner-svn-src-stable@freebsd.org Sat Jun 4 04:02:04 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C1D55B69D14; Sat, 4 Jun 2016 04:02:04 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 931BF1B15; Sat, 4 Jun 2016 04:02:04 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u54423EX054593; Sat, 4 Jun 2016 04:02:03 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u54423ut054592; Sat, 4 Jun 2016 04:02:03 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201606040402.u54423ut054592@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Sat, 4 Jun 2016 04:02:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r301299 - stable/9/sys/compat/ndis X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Jun 2016 04:02:04 -0000 Author: pfg Date: Sat Jun 4 04:02:03 2016 New Revision: 301299 URL: https://svnweb.freebsd.org/changeset/base/301299 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/9/sys/compat/ndis/subr_ntoskrnl.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/compat/ndis/subr_ntoskrnl.c ============================================================================== --- stable/9/sys/compat/ndis/subr_ntoskrnl.c Sat Jun 4 04:01:28 2016 (r301298) +++ stable/9/sys/compat/ndis/subr_ntoskrnl.c Sat Jun 4 04:02:03 2016 (r301299) @@ -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); }