From owner-svn-src-head@freebsd.org Wed Oct 12 13:56:16 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3758EC0E31B; Wed, 12 Oct 2016 13:56:16 +0000 (UTC) (envelope-from emaste@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 mx1.freebsd.org (Postfix) with ESMTPS id 06F0BBFF; Wed, 12 Oct 2016 13:56:15 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9CDuFFN013533; Wed, 12 Oct 2016 13:56:15 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9CDuF1q013531; Wed, 12 Oct 2016 13:56:15 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201610121356.u9CDuF1q013531@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Wed, 12 Oct 2016 13:56:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307148 - in head/lib/libc: gen stdlib X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 13:56:16 -0000 Author: emaste Date: Wed Oct 12 13:56:14 2016 New Revision: 307148 URL: https://svnweb.freebsd.org/changeset/base/307148 Log: Add comment on use of abort() in libc Suggested by: jonathan (in review D8133) Modified: head/lib/libc/gen/arc4random.c head/lib/libc/stdlib/random.c Modified: head/lib/libc/gen/arc4random.c ============================================================================== --- head/lib/libc/gen/arc4random.c Wed Oct 12 13:51:41 2016 (r307147) +++ head/lib/libc/gen/arc4random.c Wed Oct 12 13:56:14 2016 (r307148) @@ -144,8 +144,15 @@ arc4_stir(void) arc4_init(); rs_initialized = 1; } - if (arc4_sysctl(rdat, KEYSIZE) != KEYSIZE) - abort(); /* Random sysctl cannot fail. */ + if (arc4_sysctl(rdat, KEYSIZE) != KEYSIZE) { + /* + * The sysctl cannot fail. If it does fail on some FreeBSD + * derivative or after some future change, just abort so that + * the problem will be found and fixed. abort is not normally + * suitable for a library but makes sense here. + */ + abort(); + } arc4_addrandom(rdat, KEYSIZE); Modified: head/lib/libc/stdlib/random.c ============================================================================== --- head/lib/libc/stdlib/random.c Wed Oct 12 13:51:41 2016 (r307147) +++ head/lib/libc/stdlib/random.c Wed Oct 12 13:56:14 2016 (r307148) @@ -279,8 +279,15 @@ srandomdev(void) mib[0] = CTL_KERN; mib[1] = KERN_ARND; - if (sysctl(mib, 2, state, &len, NULL, 0) == -1 || len != expected) + if (sysctl(mib, 2, state, &len, NULL, 0) == -1 || len != expected) { + /* + * The sysctl cannot fail. If it does fail on some FreeBSD + * derivative or after some future change, just abort so that + * the problem will be found and fixed. abort is not normally + * suitable for a library but makes sense here. + */ abort(); + } if (rand_type != TYPE_0) { fptr = &state[rand_sep];