From owner-svn-src-all@freebsd.org Sat May 21 17:38:45 2016 Return-Path: Delivered-To: svn-src-all@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 29692B4337C; Sat, 21 May 2016 17:38:45 +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 EFF0C14C6; Sat, 21 May 2016 17:38:44 +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 u4LHciic025149; Sat, 21 May 2016 17:38:44 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u4LHciji025148; Sat, 21 May 2016 17:38:44 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201605211738.u4LHciji025148@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Sat, 21 May 2016 17:38:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r300376 - head/sys/compat/ndis X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 May 2016 17:38:45 -0000 Author: pfg Date: Sat May 21 17:38:43 2016 New Revision: 300376 URL: https://svnweb.freebsd.org/changeset/base/300376 Log: 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 MFC after: 2 weeks Modified: head/sys/compat/ndis/subr_ntoskrnl.c Modified: head/sys/compat/ndis/subr_ntoskrnl.c ============================================================================== --- head/sys/compat/ndis/subr_ntoskrnl.c Sat May 21 16:52:38 2016 (r300375) +++ head/sys/compat/ndis/subr_ntoskrnl.c Sat May 21 17:38:43 2016 (r300376) @@ -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); }