From owner-svn-src-all@FreeBSD.ORG Wed Jul 24 10:14:36 2013 Return-Path: Delivered-To: svn-src-all@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 83CD8900 for ; Wed, 24 Jul 2013 10:14:36 +0000 (UTC) (envelope-from mailer-daemon@vniz.net) Received: from mail-lb0-f176.google.com (mail-lb0-f176.google.com [209.85.217.176]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 0AE1427A8 for ; Wed, 24 Jul 2013 10:14:35 +0000 (UTC) Received: by mail-lb0-f176.google.com with SMTP id z5so326526lbh.35 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=mwRzM4I5MXQJjSWyQ/FwlYXFaiQTfOMlrr0VbJQtlIvt2lHnNqnN0MrWSCHXQRMRoM VsRGdN2JDACCPRJpOnFQdD69q/3Npj5Vi0eJosBy5jCB/kvuDInjhNy5yBNGBuMXav3Z tN4E7su9I6c0swHVELN9gtsVvNjo1+n94siWox3s3nJQYoIGPG8ChHAlEHQ7tHGinVtU fH7JNGqtXA77mc/I/RY4pBZnHWMzZ8RUjNDKG8T3LaInLLDzmN8i1OdqZG767XtKwd4G wzKyPwzeUf61NG+XVG+XZvsV5NetJyOQy6rPHVnfXLv+6+wWCoU/favYty+QArAjx5FR fYqw== 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: ALoCoQnz7rzghjXeP4RygAsTiDUQ41acMvWgQZrw7Q2W39KeT/SXM4j+xZeD2HY3+htqZ2TPcH/n 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-all@freebsd.org X-Mailman-Version: 2.1.14 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: 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