From owner-freebsd-hackers Wed Feb 19 1:43:13 2003 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 66D1737B401 for ; Wed, 19 Feb 2003 01:43:12 -0800 (PST) Received: from flood.ping.uio.no (flood.ping.uio.no [129.240.78.31]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5E8FC43F93 for ; Wed, 19 Feb 2003 01:43:11 -0800 (PST) (envelope-from des@ofug.org) Received: by flood.ping.uio.no (Postfix, from userid 2602) id 542EA536E; Wed, 19 Feb 2003 10:43:09 +0100 (CET) X-URL: http://www.ofug.org/~des/ X-Disclaimer: The views expressed in this message do not necessarily coincide with those of any organisation or company with which I am or have been affiliated. To: phk@phk.freebsd.dk Cc: Paul Herman , Peter Jeremy , FreeBSD Hackers Subject: Re: arc4random() range From: Dag-Erling Smorgrav Date: Wed, 19 Feb 2003 10:43:08 +0100 In-Reply-To: <86890.1045646060@critter.freebsd.dk> (phk@phk.freebsd.dk's message of "Wed, 19 Feb 2003 10:14:20 +0100") Message-ID: User-Agent: Gnus/5.090014 (Oort Gnus v0.14) Emacs/21.2 (i386--freebsd) References: <86890.1045646060@critter.freebsd.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG phk@phk.freebsd.dk writes: > Well, I'm right in principle but wrong in current practice, at > the very least make it: > > #define arc4random31() (arc4random() & RAND_MAX) or rather #define arc4random31() (arc4random() % (RAND_MAX + 1)) to avoid relying on RAND_MAX being one less than a power of two. DES -- Dag-Erling Smorgrav - des@ofug.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message