From owner-svn-src-stable-9@FreeBSD.ORG Wed Jul 24 10:14:36 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 7C4948FE for ; Wed, 24 Jul 2013 10:14:36 +0000 (UTC) (envelope-from mailer-daemon@vniz.net) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com [209.85.215.46]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 0392327A7 for ; Wed, 24 Jul 2013 10:14:35 +0000 (UTC) Received: by mail-la0-f46.google.com with SMTP id es20so164280lab.5 for ; Wed, 24 Jul 2013 03:14:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:openpgp:content-type :content-transfer-encoding:x-gm-message-state; bh=qnS64NrvnZ1HvoMD1Aab7XO0JZD3iph4zP/IMSe33Iw=; b=GYAONSfULUDzgVJB9Pw/JxuvdoFkZpZy221YZ5J3dW34RiqjgAabZfklCt03N9MSvD gRgxFT5azzowywZVrjT+rafqN7lzN+nFVJ91x2A9EwB9JpPkYdZOghdu7ul9uvKpsyGE XuSb2gv1PiWgnvwEgz33+H2MtqlNLD1Rs6/non82Hn3uNdolrmjMsTKT8osUetfEEcEl l5DNjNOk/935FcTPu+sEhlbSkKtKRgZYuB2eF/aPIP1JsVhNidT/ViyXhEl2n33yNJkc au+/6nqvFVTqEgxMCsKdNU1NZRcmB8e+ZTzPzjBxQLXSUVElpsxIg13FqqNMaUO/jQ0X G9pw== X-Received: by 10.112.58.135 with SMTP id r7mr16396038lbq.89.1374660867557; Wed, 24 Jul 2013 03:14:27 -0700 (PDT) Received: from [192.168.1.2] ([89.169.173.68]) by mx.google.com with ESMTPSA id p10sm14696269lap.8.2013.07.24.03.14.26 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 24 Jul 2013 03:14:26 -0700 (PDT) Message-ID: <51EFA902.10408@freebsd.org> Date: Wed, 24 Jul 2013 14:14:26 +0400 From: Andrey Chernov User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 MIME-Version: 1.0 To: "Andrey A. Chernov" Subject: Re: svn commit: r253607 - in stable/9: include lib/libc/stdlib References: <201307241012.r6OACoqb011294@svn.freebsd.org> In-Reply-To: <201307241012.r6OACoqb011294@svn.freebsd.org> OpenPGP: id=964474DD Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQm/XTv5g97xQXBDnwwNozpkSOtG1njujnGBnQqWn+8R/8ZOLYmwINQljBKyJF/4XVw3TfzR Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-9@freebsd.org X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Jul 2013 10:14:36 -0000 Forget to mention, it was MFC r252608,252648,252668,252698 On 24.07.2013 14:12, Andrey A. Chernov wrote: > Author: ache > Date: Wed Jul 24 10:12:50 2013 > New Revision: 253607 > URL: http://svnweb.freebsd.org/changeset/base/253607 > > Log: > 1) POSIX requires rand(3) return values to be in the [0, RAND_MAX] > range, but ACM formula we use have internal state (and return value) in > the [1, 0x7ffffffe] range, so our RAND_MAX (0x7fffffff) is never reached > because it is off by one, zero is not reached too. > > Correct both RAND_MAX and rand(3) return value, shifting last one > to the 0 by 1 subtracted, resulting POSIXed [0, 0x7ffffffd(=new > RAND_MAX)] range. > > 2) Add a checks for not overflowing on too big seeds. It may happens on > the machines, where sizeof(unsigned int) > 32 bits. > > This change is binary compatible because range is reduced, not expanded, > so no bump is needed. > > Reviewed by: bde > Approved by: re (glebius) > > Modified: > stable/9/include/stdlib.h > stable/9/lib/libc/stdlib/rand.c > Directory Properties: > stable/9/include/ (props changed) > stable/9/lib/libc/ (props changed) -- http://ache.vniz.net/ bitcoin:1G6ugdNY6e5jx1GVnAU2ntj2NEfmjKG85r