Introduce KERNEL_NAME_MAX = 255, and bump NAME_MAX to 511. This makes

NAME_MAX match MAXNAMLEN, while at the same time does not allow names
to exceed KERNEL_NAME_MAX (enforced in vfs_lookup) so that binaries
don't break.
This commit is contained in:
christos 2011-09-27 01:40:32 +00:00
parent 1e439c8185
commit 803cf26243
6 changed files with 24 additions and 13 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: dirent.h,v 1.27 2011/08/09 20:05:04 dholland Exp $ */
/* $NetBSD: dirent.h,v 1.28 2011/09/27 01:40:32 christos Exp $ */
/*-
* Copyright (c) 1989, 1993
@ -52,7 +52,7 @@ struct dirent {
uint16_t d_namlen; /* length of string in d_name */
uint8_t d_type; /* file type, see below */
#if defined(_NETBSD_SOURCE)
#define MAXNAMLEN 511
#define MAXNAMLEN 511 /* must be kept in sync with NAME_MAX */
char d_name[MAXNAMLEN + 1]; /* name must be no longer than this */
#else
char d_name[511 + 1]; /* name must be no longer than this */

View File

@ -1,4 +1,4 @@
/* $NetBSD: extattr.h,v 1.7 2011/08/03 04:11:17 manu Exp $ */
/* $NetBSD: extattr.h,v 1.8 2011/09/27 01:40:32 christos Exp $ */
/*-
* Copyright (c) 1999-2001 Robert N. M. Watson
@ -52,12 +52,12 @@
#ifdef _KERNEL
#include <sys/syslimits.h>
#include <sys/param.h>
/* VOP_LISTEXTATTR flags */
#define EXTATTR_LIST_LENPREFIX 1 /* names with length prefix */
#define EXTATTR_MAXNAMELEN NAME_MAX
#define EXTATTR_MAXNAMELEN KERNEL_NAME_MAX
struct lwp;
struct vnode;
int extattr_check_cred(struct vnode *, int, kauth_cred_t,

View File

@ -1,4 +1,4 @@
/* $NetBSD: mqueue.h,v 1.13 2011/04/24 20:17:53 rmind Exp $ */
/* $NetBSD: mqueue.h,v 1.14 2011/09/27 01:40:32 christos Exp $ */
/*
* Copyright (c) 2007-2009 Mindaugas Rasiukevicius <rmind at NetBSD org>
@ -50,6 +50,7 @@ struct mq_attr {
#include <sys/queue.h>
#include <sys/selinfo.h>
#include <sys/types.h>
#include <sys/param.h>
/*
* Flags below are used in mq_flags for internal purposes.
@ -62,7 +63,7 @@ struct mq_attr {
#define MQ_RECEIVE 0x20000000
/* Maximal length of mqueue name */
#define MQ_NAMELEN (NAME_MAX + 1)
#define MQ_NAMELEN (KERNEL_NAME_MAX + 1)
/* Default size of the message */
#define MQ_DEF_MSGSIZE 1024

View File

@ -1,4 +1,4 @@
/* $NetBSD: param.h,v 1.393 2011/09/23 14:47:41 christos Exp $ */
/* $NetBSD: param.h,v 1.394 2011/09/27 01:40:32 christos Exp $ */
/*-
* Copyright (c) 1982, 1986, 1989, 1993
@ -323,6 +323,15 @@
#define MAXPATHLEN PATH_MAX
#define MAXSYMLINKS 32
/*
* This is the maximum individual filename component length enforced by
* namei. Filesystems cannot exceed this limit. The upper bound for that
* limit is NAME_MAX. We don't bump it for now, for compatibility with
* old binaries during the time where MAXPATHLEN was 511 and NAME_MAX was
* 255
*/
#define KERNEL_NAME_MAX 255
/* Bit map related macros. */
#define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
#define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))

View File

@ -1,4 +1,4 @@
/* $NetBSD: syslimits.h,v 1.24 2008/02/25 17:29:13 ad Exp $ */
/* $NetBSD: syslimits.h,v 1.25 2011/09/27 01:40:32 christos Exp $ */
/*
* Copyright (c) 1988, 1993
@ -46,7 +46,8 @@
#define LINK_MAX 32767 /* max file link count */
#define MAX_CANON 255 /* max bytes in term canon input line */
#define MAX_INPUT 255 /* max bytes in terminal input */
#define NAME_MAX 255 /* max bytes in a file name */
#define NAME_MAX 511 /* max bytes in a file name, must be
/* kept in sync with MAXPATHLEN */
#define NGROUPS_MAX 16 /* max supplemental group id's */
#define UID_MAX 2147483647U /* max value for a uid_t (2^31-2) */
#ifndef OPEN_MAX

View File

@ -1,4 +1,4 @@
/* $NetBSD: xattr.h,v 1.4 2011/07/18 11:28:24 drochner Exp $ */
/* $NetBSD: xattr.h,v 1.5 2011/09/27 01:40:32 christos Exp $ */
/*-
* Copyright (c) 2005 The NetBSD Foundation, Inc.
@ -41,13 +41,13 @@
#define _SYS_XATTR_H_
#include <sys/types.h>
#include <sys/syslimits.h>
#include <sys/param.h>
/*
* This is compatible with EXTATTR_MAXNAMELEN, and also happens to be
* the same as Linux (255).
*/
#define XATTR_NAME_MAX NAME_MAX
#define XATTR_NAME_MAX KERNEL_NAME_MAX
#define XATTR_SIZE_MAX 65536 /* NetBSD does not enforce this */