Page MenuHomeFreeBSD

D12330.id32947.diff
No OneTemporary

D12330.id32947.diff

Index: include/limits.h
===================================================================
--- include/limits.h
+++ include/limits.h
@@ -128,8 +128,8 @@
#if __XSI_VISIBLE
#define _XOPEN_IOV_MAX 16
-#define _XOPEN_NAME_MAX 255
-#define _XOPEN_PATH_MAX 1024
+#define _XOPEN_NAME_MAX 1023
+#define _XOPEN_PATH_MAX 4096
#define PASS_MAX 128 /* _PASSWORD_LEN from <pwd.h> */
#define NL_LANGMAX 31 /* max LANG name length */
Index: include/stdio.h
===================================================================
--- include/stdio.h
+++ include/stdio.h
@@ -211,7 +211,7 @@
#ifndef FOPEN_MAX
#define FOPEN_MAX 20 /* must be <= OPEN_MAX <sys/syslimits.h> */
#endif
-#define FILENAME_MAX 1024 /* must be <= PATH_MAX <sys/syslimits.h> */
+#define FILENAME_MAX 4096 /* must be <= PATH_MAX <sys/syslimits.h> */
/* System V/ANSI C; this is the wrong way to do this, do *not* use these. */
#if __XSI_VISIBLE
Index: lib/libc/gen/glob.c
===================================================================
--- lib/libc/gen/glob.c
+++ lib/libc/gen/glob.c
@@ -189,11 +189,16 @@
{
struct glob_limit limit = { 0, 0, 0, 0, 0 };
const char *patnext;
- Char *bufnext, *bufend, patbuf[MAXPATHLEN], prot;
+ Char *bufnext, *bufend, *patbuf, prot;
mbstate_t mbs;
wchar_t wc;
size_t clen;
- int too_long;
+ int too_long, error;
+
+ error = 0;
+ patbuf = malloc(MAXPATHLEN * sizeof(*patbuf));
+ if (patbuf == NULL)
+ return (GLOB_NOSPACE);
patnext = pattern;
if (!(flags & GLOB_APPEND)) {
@@ -218,9 +223,10 @@
memset(&mbs, 0, sizeof(mbs));
while (bufnext <= bufend) {
clen = mbrtowc(&wc, patnext, MB_LEN_MAX, &mbs);
- if (clen == (size_t)-1 || clen == (size_t)-2)
- return (err_nomatch(pglob, &limit, pattern));
- else if (clen == 0) {
+ if (clen == (size_t)-1 || clen == (size_t)-2) {
+ error = err_nomatch(pglob, &limit, pattern);
+ goto out;
+ } else if (clen == 0) {
too_long = 0;
break;
}
@@ -240,9 +246,10 @@
} else
prot = 0;
clen = mbrtowc(&wc, patnext, MB_LEN_MAX, &mbs);
- if (clen == (size_t)-1 || clen == (size_t)-2)
- return (err_nomatch(pglob, &limit, pattern));
- else if (clen == 0) {
+ if (clen == (size_t)-1 || clen == (size_t)-2) {
+ error = err_nomatch(pglob, &limit, pattern);
+ goto out;
+ } else if (clen == 0) {
too_long = 0;
break;
}
@@ -250,14 +257,20 @@
patnext += clen;
}
}
- if (too_long)
- return (err_nomatch(pglob, &limit, pattern));
+ if (too_long) {
+ error = err_nomatch(pglob, &limit, pattern);
+ goto out;
+ }
*bufnext = EOS;
if (flags & GLOB_BRACE)
- return (globexp0(patbuf, pglob, &limit, pattern));
+ error = globexp0(patbuf, pglob, &limit, pattern);
else
- return (glob0(patbuf, pglob, &limit, pattern));
+ error = glob0(patbuf, pglob, &limit, pattern);
+
+out:
+ free(patbuf);
+ return (error);
}
static int
@@ -534,12 +547,17 @@
const Char *qpatnext;
int err;
size_t oldpathc;
- Char *bufnext, c, patbuf[MAXPATHLEN];
+ Char *bufnext, c, *patbuf;
+
+ patbuf = malloc(MAXPATHLEN * sizeof(*patbuf));
+ if (patbuf == NULL)
+ return (GLOB_NOSPACE);
qpatnext = globtilde(pattern, patbuf, MAXPATHLEN, pglob);
if (qpatnext == NULL) {
errno = E2BIG;
- return (GLOB_NOSPACE);
+ err = GLOB_NOSPACE;
+ goto out;
}
oldpathc = pglob->gl_pathc;
bufnext = patbuf;
@@ -598,12 +616,14 @@
#endif
if ((err = glob1(patbuf, pglob, limit)) != 0)
- return(err);
+ goto out;
if (origpat != NULL)
- return (globfinal(pglob, limit, oldpathc, origpat));
+ err = globfinal(pglob, limit, oldpathc, origpat);
- return (0);
+out:
+ free(patbuf);
+ return (err);
}
static int
Index: sys/sys/dirent.h
===================================================================
--- sys/sys/dirent.h
+++ sys/sys/dirent.h
@@ -70,10 +70,10 @@
__uint16_t d_namlen; /* length of string in d_name */
__uint16_t d_pad1;
#if __BSD_VISIBLE
-#define MAXNAMLEN 255
+#define MAXNAMLEN 1023
char d_name[MAXNAMLEN + 1]; /* name must be no longer than this */
#else
- char d_name[255 + 1]; /* name must be no longer than this */
+ char d_name[1023 + 1]; /* name must be no longer than this */
#endif
};
Index: sys/sys/extattr.h
===================================================================
--- sys/sys/extattr.h
+++ sys/sys/extattr.h
@@ -57,7 +57,7 @@
EXTATTR_NAMESPACE_USER_STRING, \
EXTATTR_NAMESPACE_SYSTEM_STRING }
-#define EXTATTR_MAXNAMELEN NAME_MAX
+#define EXTATTR_MAXNAMELEN 255
#ifdef _KERNEL
#include <sys/types.h>
Index: sys/sys/linker.h
===================================================================
--- sys/sys/linker.h
+++ sys/sys/linker.h
@@ -303,7 +303,7 @@
*/
struct kld_file_stat_1 {
int version; /* set to sizeof(struct kld_file_stat_1) */
- char name[MAXPATHLEN];
+ char name[OLD_PATH_MAX];
int refs;
int id;
caddr_t address; /* load address */
@@ -313,12 +313,12 @@
struct kld_file_stat {
int version; /* set to sizeof(struct kld_file_stat) */
- char name[MAXPATHLEN];
+ char name[OLD_PATH_MAX];
int refs;
int id;
caddr_t address; /* load address */
size_t size; /* size in bytes */
- char pathname[MAXPATHLEN];
+ char pathname[OLD_PATH_MAX];
};
struct kld_sym_lookup {
Index: sys/sys/param.h
===================================================================
--- sys/sys/param.h
+++ sys/sys/param.h
@@ -101,7 +101,7 @@
#include <sys/syslimits.h>
#define MAXCOMLEN 19 /* max command name remembered */
-#define MAXINTERP PATH_MAX /* max interpreter file name length */
+#define MAXINTERP OLD_PATH_MAX /* max interpreter file name length */
#define MAXLOGNAME 33 /* max login name length (incl. NUL) */
#define MAXUPRC CHILD_MAX /* max simultaneous processes */
#define NCARGS ARG_MAX /* max bytes for an exec function */
Index: sys/sys/syslimits.h
===================================================================
--- sys/sys/syslimits.h
+++ sys/sys/syslimits.h
@@ -53,14 +53,15 @@
#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 1023 /* max bytes in a file name */
#ifndef NGROUPS_MAX
#define NGROUPS_MAX 1023 /* max supplemental group id's */
#endif
#ifndef OPEN_MAX
#define OPEN_MAX 64 /* max open files per process */
#endif
-#define PATH_MAX 1024 /* max bytes in pathname */
+#define PATH_MAX 4096 /* max bytes in pathname */
+#define OLD_PATH_MAX 1024
#define PIPE_BUF 512 /* max bytes for atomic pipe writes */
#define IOV_MAX 1024 /* max elements in i/o vector */
Index: sys/sys/user.h
===================================================================
--- sys/sys/user.h
+++ sys/sys/user.h
@@ -319,7 +319,7 @@
int kf_sock_domain; /* Socket domain. */
int kf_sock_type; /* Socket type. */
int kf_sock_protocol; /* Socket protocol. */
- char kf_path[PATH_MAX]; /* Path to file, if any. */
+ char kf_path[OLD_PATH_MAX]; /* Path to file, if any. */
struct sockaddr_storage kf_sa_local; /* Socket address. */
struct sockaddr_storage kf_sa_peer; /* Peer address. */
};
@@ -429,7 +429,7 @@
cap_rights_t kf_cap_rights; /* Capability rights. */
uint64_t _kf_cap_spare; /* Space for future cap_rights_t. */
/* Truncated before copyout in sysctl */
- char kf_path[PATH_MAX]; /* Path to file, if any. */
+ char kf_path[OLD_PATH_MAX]; /* Path to file, if any. */
};
#ifndef _KERNEL
#define kf_vnode_type kf_un.kf_file.kf_file_type
@@ -482,7 +482,7 @@
int kve_protection; /* Protection bitmask. */
int kve_ref_count; /* VM obj ref count. */
int kve_shadow_count; /* VM obj shadow count. */
- char kve_path[PATH_MAX]; /* Path to VM obj, if any. */
+ char kve_path[OLD_PATH_MAX]; /* Path to VM obj, if any. */
void *_kve_pspare[8]; /* Space for more stuff. */
off_t kve_offset; /* Mapping offset in object */
uint64_t kve_fileid; /* inode number if vnode */
@@ -517,7 +517,7 @@
uint64_t kve_vn_rdev; /* Device id if device. */
int _kve_ispare[8]; /* Space for more stuff. */
/* Truncated before copyout in sysctl */
- char kve_path[PATH_MAX]; /* Path to VM obj, if any. */
+ char kve_path[OLD_PATH_MAX]; /* Path to VM obj, if any. */
};
/*
@@ -539,7 +539,7 @@
uint64_t kvo_vn_fsid;
uint64_t _kvo_qspare[7];
uint32_t _kvo_ispare[8];
- char kvo_path[PATH_MAX]; /* Pathname, if any. */
+ char kvo_path[OLD_PATH_MAX]; /* Pathname, if any. */
};
/*
Index: sys/ufs/ufs/ufs_lookup.c
===================================================================
--- sys/ufs/ufs/ufs_lookup.c
+++ sys/ufs/ufs/ufs_lookup.c
@@ -224,6 +224,9 @@
if (dp->i_effnlink == 0)
return (ENOENT);
+ if (cnp->cn_namelen > UFS_MAXNAMLEN)
+ return (ENAMETOOLONG);
+
/*
* Create a vm object if vmiodirenable is enabled.
* Alternatively we could call vnode_create_vobject

File Metadata

Mime Type
text/plain
Expires
Tue, Apr 7, 6:59 AM (19 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31017560
Default Alt Text
D12330.id32947.diff (8 KB)

Event Timeline