From owner-freebsd-current Sun Feb 2 1:31:48 2003 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1F93D37B401 for ; Sun, 2 Feb 2003 01:31:47 -0800 (PST) Received: from critter.freebsd.dk (critter.freebsd.dk [212.242.86.163]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4B70243F43 for ; Sun, 2 Feb 2003 01:31:46 -0800 (PST) (envelope-from phk@freebsd.org) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.12.6/8.12.6) with ESMTP id h129Vd4W033365; Sun, 2 Feb 2003 10:31:39 +0100 (CET) (envelope-from phk@freebsd.org) To: "Andrey A. Chernov" Cc: Kris Kennaway , current@freebsd.org Subject: Re: rand() is broken From: phk@freebsd.org In-Reply-To: Your message of "Sun, 02 Feb 2003 12:27:18 +0300." <20030202092718.GA60116@nagual.pp.ru> Date: Sun, 02 Feb 2003 10:31:39 +0100 Message-ID: <33364.1044178299@critter.freebsd.dk> Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG In message <20030202092718.GA60116@nagual.pp.ru>, "Andrey A. Chernov" writes: > >--SUOF0GtieIMvvwua >Content-Type: text/plain; charset=us-ascii >Content-Disposition: inline >Content-Transfer-Encoding: quoted-printable > >On Sun, Feb 02, 2003 at 01:11:06 -0800, Kris Kennaway wrote: >>=20 >> Another problem (noticed by tjr) is that once the sequence hits '0' it >> jumps to INT_MAX and stays there forever. For example, seeding with >> srand(0) produces nothing but INT_MAX from rand(). >>=20 >> It looks like a lot more validation of this PRNG is needed. > >Don't have an idea about this thing yet, maybe some sign or variable size= >=20 >change fix required. > >BTW, note that new formulae also used in the kernel (by BSD developers) >and taken from there - libkern/random.c - so all you say is true there >too. It should be nuked from the kernel, and arc4random() used instead. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message