Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/usermode/usermode more checking



details:   https://anonhg.NetBSD.org/src/rev/1baeac284d4c
branches:  trunk
changeset: 812572:1baeac284d4c
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Dec 21 19:54:35 2015 +0000

description:
more checking

diffstat:

 sys/arch/usermode/usermode/thunk.c |  14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diffs (41 lines):

diff -r c6d1fd880986 -r 1baeac284d4c sys/arch/usermode/usermode/thunk.c
--- a/sys/arch/usermode/usermode/thunk.c        Mon Dec 21 17:17:02 2015 +0000
+++ b/sys/arch/usermode/usermode/thunk.c        Mon Dec 21 19:54:35 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.c,v 1.85 2015/02/06 10:25:13 prlw1 Exp $ */
+/* $NetBSD: thunk.c,v 1.86 2015/12/21 19:54:35 christos Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -28,7 +28,7 @@
 
 #include <sys/cdefs.h>
 #ifdef __NetBSD__
-__RCSID("$NetBSD: thunk.c,v 1.85 2015/02/06 10:25:13 prlw1 Exp $");
+__RCSID("$NetBSD: thunk.c,v 1.86 2015/12/21 19:54:35 christos Exp $");
 #endif
 
 #include <sys/types.h>
@@ -761,15 +761,19 @@
 
        fd = open("/proc/cpuinfo", O_RDONLY);
        if (fd == -1)
-               return -1;
-       rlen = read(fd, cp, *len - 1);
+               goto out;
+       rlen = read(fd, cp, *len);
        close(fd);
 
        if (rlen == -1)
-               return -1;
+               goto out;
 
+       buf[rlen ? rlen - 1 : 0] = '\0';
        *len = rlen;
        return 0;
+bad:
+       *len = 0;
+       return -1;
 }
 
 int



Home | Main Index | Thread Index | Old Index