From owner-svn-src-all@freebsd.org Sun May 15 06:06:23 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 C0AB2B3C7BE; Sun, 15 May 2016 06:06:23 +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 91C5F1745; Sun, 15 May 2016 06:06:23 +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 u4F66MPV007499; Sun, 15 May 2016 06:06:22 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u4F66MLv007498; Sun, 15 May 2016 06:06:22 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201605150606.u4F66MLv007498@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Sun, 15 May 2016 06:06:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r299845 - head/sbin/routed 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: Sun, 15 May 2016 06:06:23 -0000 Author: pfg Date: Sun May 15 06:06:22 2016 New Revision: 299845 URL: https://svnweb.freebsd.org/changeset/base/299845 Log: routed(8): Use arc4random_uniform instead of arc4random. Use arc4random_uniform() when the desired random number upper bound is not a power of two. While here, we don't need srandom() and friends anymore. Obtained from: OpenBSD (CVS rev. 1.20) Modified: head/sbin/routed/main.c Modified: head/sbin/routed/main.c ============================================================================== --- head/sbin/routed/main.c Sun May 15 06:00:13 2016 (r299844) +++ head/sbin/routed/main.c Sun May 15 06:06:22 2016 (r299845) @@ -303,11 +303,6 @@ usage: pidfile(0); #endif mypid = getpid(); -#ifdef __FreeBSD__ - srandomdev(); -#else - srandom((int)(clk.tv_sec ^ clk.tv_usec ^ mypid)); -#endif /* prepare socket connected to the kernel. */ @@ -826,8 +821,8 @@ intvl_random(struct timeval *tp, /* put { tp->tv_sec = (time_t)(hi == lo ? lo - : (lo + arc4random() % ((hi - lo)))); - tp->tv_usec = arc4random() % 1000000; + : (lo + arc4random_uniform(1 + hi - lo))); + tp->tv_usec = arc4random_uniform(1000000); }