Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/puffs/mount_sysctlfs - protect against node not fou...



details:   https://anonhg.NetBSD.org/src/rev/622a5a1e2597
branches:  trunk
changeset: 819229:622a5a1e2597
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Nov 23 17:22:44 2016 +0000

description:
- protect against node not found SEGV
- fix reversed logic; if we find it in the cache we return it, otherwise
  we create it.

diffstat:

 usr.sbin/puffs/mount_sysctlfs/sysctlfs.c |  10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diffs (38 lines):

diff -r 5eec06940244 -r 622a5a1e2597 usr.sbin/puffs/mount_sysctlfs/sysctlfs.c
--- a/usr.sbin/puffs/mount_sysctlfs/sysctlfs.c  Wed Nov 23 16:11:34 2016 +0000
+++ b/usr.sbin/puffs/mount_sysctlfs/sysctlfs.c  Wed Nov 23 17:22:44 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sysctlfs.c,v 1.18 2015/11/12 16:51:18 christos Exp $   */
+/*     $NetBSD: sysctlfs.c,v 1.19 2016/11/23 17:22:44 christos Exp $   */
 
 /*-
  * Copyright (c) 2006, 2007  Antti Kantee.  All Rights Reserved.
@@ -33,7 +33,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: sysctlfs.c,v 1.18 2015/11/12 16:51:18 christos Exp $");
+__RCSID("$NetBSD: sysctlfs.c,v 1.19 2016/11/23 17:22:44 christos Exp $");
 #endif /* !lint */
 
 #include <sys/types.h>
@@ -180,8 +180,8 @@
        else
                pn = puffs_pn_nodewalk(pu, puffs_path_walkcmp, po);
 
-       if (pn == NULL) 
-               return NULL;
+       if (pn != NULL) 
+               return pn;
        /*
         * don't know nodetype?  query...
         *
@@ -580,6 +580,8 @@
                nodetype = CTLTYPE_NODE;
 
        pn_new = getnode(pu, &p2cn->pcn_po_full, nodetype);
+       if (pn_new == NULL)
+               return ENOENT;
        sfs_new = pn_new->pn_data;
 
        puffs_newinfo_setcookie(pni, pn_new);



Home | Main Index | Thread Index | Old Index