From owner-svn-src-all@freebsd.org Thu Jan 16 21:38:44 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B939F1F6FA4; Thu, 16 Jan 2020 21:38:44 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47zHd0432sz4dlr; Thu, 16 Jan 2020 21:38:44 +0000 (UTC) (envelope-from cem@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8646026144; Thu, 16 Jan 2020 21:38:44 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 00GLcijC051083; Thu, 16 Jan 2020 21:38:44 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00GLciwT051082; Thu, 16 Jan 2020 21:38:44 GMT (envelope-from cem@FreeBSD.org) Message-Id: <202001162138.00GLciwT051082@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: Conrad Meyer Date: Thu, 16 Jan 2020 21:38:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r356810 - head/usr.bin/random X-SVN-Group: head X-SVN-Commit-Author: cem X-SVN-Commit-Paths: head/usr.bin/random X-SVN-Commit-Revision: 356810 X-SVN-Commit-Repository: base 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.29 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: Thu, 16 Jan 2020 21:38:44 -0000 Author: cem Date: Thu Jan 16 21:38:44 2020 New Revision: 356810 URL: https://svnweb.freebsd.org/changeset/base/356810 Log: random(6): Fix off-by-one After r355693, random(6) -f sometimes fail to output all the lines of the input file. This is because the range from which random indices are chosen is too big, so occasionally the random selection doesn't correspond to any line and nothing gets printed. (Ed. note: Mea culpa. Working on r355693, I was confused by the sometime use of 1-indexing, sometimes 0-indexing in randomize_fd().) Submitted by: Ryan Moeller X-MFC-With: r355693 Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D23199 Modified: head/usr.bin/random/randomize_fd.c Modified: head/usr.bin/random/randomize_fd.c ============================================================================== --- head/usr.bin/random/randomize_fd.c Thu Jan 16 21:31:56 2020 (r356809) +++ head/usr.bin/random/randomize_fd.c Thu Jan 16 21:38:44 2020 (r356810) @@ -211,7 +211,7 @@ make_token: free(buf); for (i = numnode; i > 0; i--) { - selected = arc4random_uniform(numnode + 1); + selected = arc4random_uniform(numnode); for (j = 0, prev = n = rand_root; n != NULL; j++, prev = n, n = n->next) { if (j == selected) {