Source-Changes-HG archive

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

[src/trunk]: src/sys/kern use KERNEL_NAME_MAX to enforce the same limit to na...



details:   https://anonhg.NetBSD.org/src/rev/057942a94dcd
branches:  trunk
changeset: 769941:057942a94dcd
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Sep 27 01:42:45 2011 +0000

description:
use KERNEL_NAME_MAX to enforce the same limit to names as before, and
make sure that MAXNAMLEN == NAME_MAX

diffstat:

 sys/kern/vfs_lookup.c |  12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diffs (54 lines):

diff -r 6e8dc3b957f8 -r 057942a94dcd sys/kern/vfs_lookup.c
--- a/sys/kern/vfs_lookup.c     Tue Sep 27 01:40:32 2011 +0000
+++ b/sys/kern/vfs_lookup.c     Tue Sep 27 01:42:45 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_lookup.c,v 1.190 2011/09/01 15:31:27 yamt Exp $    */
+/*     $NetBSD: vfs_lookup.c,v 1.191 2011/09/27 01:42:45 christos Exp $        */
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.190 2011/09/01 15:31:27 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.191 2011/09/27 01:42:45 christos Exp $");
 
 #include "opt_magiclinks.h"
 
@@ -63,6 +63,8 @@
 
 int vfs_magiclinks = MAGICLINKS;
 
+__CTASSERT(MAXNAMLEN == NAME_MAX);
+
 /*
  * Substitute replacement text for 'magic' strings in symlinks.
  * Returns 0 if successful, and returns non-zero if an error
@@ -810,7 +812,7 @@
        cp = NULL;
        cnp->cn_hash = namei_hash(cnp->cn_nameptr, &cp);
        cnp->cn_namelen = cp - cnp->cn_nameptr;
-       if (cnp->cn_namelen > NAME_MAX) {
+       if (cnp->cn_namelen > KERNEL_NAME_MAX) {
                return ENAMETOOLONG;
        }
 #ifdef NAMEI_DIAGNOSTIC
@@ -1545,7 +1547,7 @@
        cp = NULL;
        cnp->cn_hash = namei_hash(cnp->cn_nameptr, &cp);
        cnp->cn_namelen = cp - cnp->cn_nameptr;
-       KASSERT(cnp->cn_namelen <= NAME_MAX);
+       KASSERT(cnp->cn_namelen <= KERNEL_NAME_MAX);
        ndp->ni_pathlen -= cnp->cn_namelen;
        ndp->ni_next = cp;
        state->slashes = 0;
@@ -1606,7 +1608,7 @@
         * Note: the name sent in here (is not|should not be) allowed
         * to contain a slash.
         */
-       if (strlen(ndp->ni_pathbuf->pb_path) > NAME_MAX) {
+       if (strlen(ndp->ni_pathbuf->pb_path) > KERNEL_NAME_MAX) {
                return ENAMETOOLONG;
        }
        if (strchr(ndp->ni_pathbuf->pb_path, '/')) {



Home | Main Index | Thread Index | Old Index