Module Name: src Committed By: riastradh Date: Sat Oct 4 11:23:35 UTC 2014
Modified Files: src/sbin/gpt: gpt_uuid.c Log Message: Paranoia: choke noisily on EOF from /dev/urandom. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sbin/gpt/gpt_uuid.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sbin/gpt/gpt_uuid.c diff -u src/sbin/gpt/gpt_uuid.c:1.8 src/sbin/gpt/gpt_uuid.c:1.9 --- src/sbin/gpt/gpt_uuid.c:1.8 Sat Oct 4 10:30:13 2014 +++ src/sbin/gpt/gpt_uuid.c Sat Oct 4 11:23:35 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: gpt_uuid.c,v 1.8 2014/10/04 10:30:13 riastradh Exp $ */ +/* $NetBSD: gpt_uuid.c,v 1.9 2014/10/04 11:23:35 riastradh Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #include <sys/cdefs.h> #ifdef __RCSID -__RCSID("$NetBSD: gpt_uuid.c,v 1.8 2014/10/04 10:30:13 riastradh Exp $"); +__RCSID("$NetBSD: gpt_uuid.c,v 1.9 2014/10/04 11:23:35 riastradh Exp $"); #endif #include <err.h> @@ -252,6 +252,8 @@ gpt_uuid_generate(gpt_uuid_t t) nread = read(fd, p, n); if (nread < 0) err(1, "read(/dev/urandom)"); + if (nread == 0) + errx(1, "EOF from /dev/urandom"); if ((size_t)nread > n) errx(1, "read too much: %zd > %zu", nread, n); }