From owner-svn-src-stable-10@freebsd.org Sat Jun 4 04:01:29 2016 Return-Path: Delivered-To: svn-src-stable-10@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 96BA8B69CBB; Sat, 4 Jun 2016 04:01:29 +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 6385F1961; Sat, 4 Jun 2016 04:01:29 +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 u5441SUf054514; Sat, 4 Jun 2016 04:01:28 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5441SwX054513; Sat, 4 Jun 2016 04:01:28 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201606040401.u5441SwX054513@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:01:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301298 - stable/10/sys/compat/ndis X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Jun 2016 04:01:29 -0000 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); }