Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/gpt Paranoia: choke noisily on EOF from /dev/urandom.



details:   https://anonhg.NetBSD.org/src/rev/7dee7a924da7
branches:  trunk
changeset: 332689:7dee7a924da7
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sat Oct 04 11:23:35 2014 +0000

description:
Paranoia: choke noisily on EOF from /dev/urandom.

diffstat:

 sbin/gpt/gpt_uuid.c |  6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (27 lines):

diff -r d6a719e412d1 -r 7dee7a924da7 sbin/gpt/gpt_uuid.c
--- a/sbin/gpt/gpt_uuid.c       Sat Oct 04 11:15:44 2014 +0000
+++ b/sbin/gpt/gpt_uuid.c       Sat Oct 04 11:23:35 2014 +0000
@@ -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 @@
                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);
        }



Home | Main Index | Thread Index | Old Index