From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/6902 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: getrandom syscall Date: Wed, 28 Jan 2015 11:21:04 -0500 Message-ID: <20150128162104.GJ4574@brightrain.aerifal.cx> References: <20150128145410.GH4574@brightrain.aerifal.cx> <20150128154108.GH32318@port70.net> <20150128160352.GI32318@port70.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1422462080 32532 80.91.229.3 (28 Jan 2015 16:21:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 28 Jan 2015 16:21:20 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-6915-gllmg-musl=m.gmane.org@lists.openwall.com Wed Jan 28 17:21:19 2015 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1YGVMk-0001dw-OM for gllmg-musl@m.gmane.org; Wed, 28 Jan 2015 17:21:18 +0100 Original-Received: (qmail 16215 invoked by uid 550); 28 Jan 2015 16:21:17 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 16201 invoked from network); 28 Jan 2015 16:21:16 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:6902 Archived-At: On Wed, Jan 28, 2015 at 05:12:31PM +0100, Daniel Cegiełka wrote: > > int getentropy(void *buf, size_t buflen) > { > int ret; > > if (buflen > 256) > goto failure; > ret = getrandom(buf, buflen, 0); > if (ret < 0) > return ret; > if (ret == buflen) > return 0; > failure: > errno = EIO; > return -1; > } Is it intentional to fall through to failure when ret is positive but less than buflen? Can this happen? > #include "syscall.h" > > int getrandom(void *buf, size_t buflen, unsigned int flags) > { > return syscall(SYS_getrandom, buf, buflen, flags); > } If I read the documentation correctly, the removed EINTR handling is irrelevant since the kernel guarantees not to EINTR for <=256 bytes with the default flags, right? Rich