PR/33163: Auster Vl.: fts: cant allocate memory | filename too long
Change the ftp_pathlen and fts_namelen to u_int from u_short so that pathnames > 32K work.
This commit is contained in:
parent
a559f08510
commit
8d5214b18a
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: fts.h,v 1.14 2005/09/13 01:44:32 christos Exp $ */
|
||||
/* $NetBSD: fts.h,v 1.15 2006/03/30 01:23:50 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
|
@ -43,6 +43,9 @@
|
|||
#ifndef __fts_ino_t
|
||||
#define __fts_ino_t ino_t
|
||||
#endif
|
||||
#ifndef __fts_length_t
|
||||
#define __fts_length_t u_int
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
struct _ftsent *fts_cur; /* current node */
|
||||
|
@ -81,8 +84,8 @@ typedef struct _ftsent {
|
|||
char *fts_path; /* root path */
|
||||
int fts_errno; /* errno for this node */
|
||||
int fts_symfd; /* fd for symlink */
|
||||
u_short fts_pathlen; /* strlen(fts_path) */
|
||||
u_short fts_namelen; /* strlen(fts_name) */
|
||||
__fts_length_t fts_pathlen; /* strlen(fts_path) */
|
||||
__fts_length_t fts_namelen; /* strlen(fts_name) */
|
||||
|
||||
__fts_ino_t fts_ino; /* inode */
|
||||
dev_t fts_dev; /* device */
|
||||
|
@ -127,12 +130,12 @@ typedef struct _ftsent {
|
|||
|
||||
__BEGIN_DECLS
|
||||
#ifndef __LIBC12_SOURCE__
|
||||
FTSENT *fts_children(FTS *, int) __RENAME(__fts_children30);
|
||||
int fts_close(FTS *) __RENAME(__fts_close30);
|
||||
FTSENT *fts_children(FTS *, int) __RENAME(__fts_children31);
|
||||
int fts_close(FTS *) __RENAME(__fts_close31);
|
||||
FTS *fts_open(char * const *, int,
|
||||
int (*)(const FTSENT **, const FTSENT **)) __RENAME(__fts_open30);
|
||||
FTSENT *fts_read(FTS *) __RENAME(__fts_read30);
|
||||
int fts_set(FTS *, FTSENT *, int) __RENAME(__fts_set30);
|
||||
int (*)(const FTSENT **, const FTSENT **)) __RENAME(__fts_open31);
|
||||
FTSENT *fts_read(FTS *) __RENAME(__fts_read31);
|
||||
int fts_set(FTS *, FTSENT *, int) __RENAME(__fts_set31);
|
||||
#endif
|
||||
__END_DECLS
|
||||
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
# $NetBSD: Makefile.inc,v 1.3 2006/03/26 18:11:22 christos Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.4 2006/03/30 01:23:50 christos Exp $
|
||||
|
||||
.PATH: ${COMPATDIR}/gen
|
||||
SRCS+=compat_errlist.c compat_fts.c compat___fts13.c compat_getmntinfo.c \
|
||||
compat_glob.c compat_opendir.c compat_readdir.c compat_scandir.c \
|
||||
compat_siglist.c compat_signame.c compat_sigsetops.c compat_times.c \
|
||||
compat_timezone.c compat_unvis.c compat_utmpx.c compat__sys_errlist.c \
|
||||
compat__sys_nerr.c compat__sys_siglist.c compat___glob13.c
|
||||
SRCS+=compat_errlist.c compat_fts.c compat___fts13.c compat___fts30.c \
|
||||
compat_getmntinfo.c compat_glob.c compat___glob13.c compat_opendir.c \
|
||||
compat_readdir.c compat_scandir.c compat_siglist.c compat_signame.c \
|
||||
compat_sigsetops.c compat_times.c compat_timezone.c compat_unvis.c \
|
||||
compat_utmpx.c compat__sys_errlist.c compat__sys_nerr.c \
|
||||
compat__sys_siglist.c
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
/* $NetBSD: compat___fts30.c,v 1.1 2006/03/30 01:23:50 christos Exp $ */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/cdefs.h>
|
||||
#include <dirent.h>
|
||||
|
||||
__warn_references(__fts_children30,
|
||||
"warning: reference to compatibility __fts_children30();"
|
||||
" include <fts.h> for correct reference")
|
||||
__warn_references(__fts_close30,
|
||||
"warning: reference to compatibility __fts_close30();"
|
||||
" include <fts.h> for correct reference")
|
||||
__warn_references(__fts_open30,
|
||||
"warning: reference to compatibility __fts_open30();"
|
||||
" include <fts.h> for correct reference")
|
||||
__warn_references(__fts_read30,
|
||||
"warning: reference to compatibility __fts_read30();"
|
||||
" include <fts.h> for correct reference")
|
||||
__warn_references(__fts_set30,
|
||||
"warning: reference to compatibility __fts_set30();"
|
||||
" include <fts.h> for correct reference")
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#define __fts_length_t u_short
|
||||
|
||||
#undef fts_children
|
||||
#define fts_children __fts_children30
|
||||
#undef fts_close
|
||||
#define fts_close __fts_close30
|
||||
#undef fts_open
|
||||
#define fts_open __fts_open30
|
||||
#undef fts_read
|
||||
#define fts_read __fts_read30
|
||||
#undef fts_set
|
||||
#define fts_set __fts_set30
|
||||
|
||||
#define __LIBC12_SOURCE__
|
||||
#include <fts.h>
|
||||
#include <compat/include/fts.h>
|
||||
|
||||
#define __FTS_COMPAT_LENGTH
|
||||
|
||||
#include "gen/fts.c"
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: fts.c,v 1.30 2006/03/19 02:01:50 christos Exp $ */
|
||||
/* $NetBSD: fts.c,v 1.31 2006/03/30 01:23:50 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993, 1994
|
||||
|
@ -38,7 +38,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: fts.c,v 1.30 2006/03/19 02:01:50 christos Exp $");
|
||||
__RCSID("$NetBSD: fts.c,v 1.31 2006/03/30 01:23:50 christos Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
|
@ -762,6 +762,7 @@ mem1: saved_errno = errno;
|
|||
maxlen = sp->fts_pathlen - len;
|
||||
}
|
||||
|
||||
#if defined(__FTS_COMPAT_LENGTH)
|
||||
if (len + dnamlen >= USHRT_MAX) {
|
||||
/*
|
||||
* In an FTSENT, fts_pathlen is a u_short so it is
|
||||
|
@ -777,6 +778,7 @@ mem1: saved_errno = errno;
|
|||
errno = ENAMETOOLONG;
|
||||
return (NULL);
|
||||
}
|
||||
#endif
|
||||
p->fts_level = level;
|
||||
p->fts_pathlen = len + dnamlen;
|
||||
p->fts_parent = sp->fts_cur;
|
||||
|
@ -1097,7 +1099,7 @@ fts_palloc(FTS *sp, size_t size)
|
|||
|
||||
_DIAGASSERT(sp != NULL);
|
||||
|
||||
#if 1
|
||||
#ifdef __FTS_COMPAT_LENGTH
|
||||
/* Protect against fts_pathlen overflow. */
|
||||
if (size > USHRT_MAX + 1) {
|
||||
errno = ENAMETOOLONG;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: shlib_version,v 1.172 2006/03/15 17:35:17 kleink Exp $
|
||||
# $NetBSD: shlib_version,v 1.173 2006/03/30 01:23:50 christos Exp $
|
||||
# Remember to update distrib/sets/lists/base/shl.* when changing
|
||||
#
|
||||
# things we wish to do on next major version bump:
|
||||
|
@ -17,4 +17,4 @@
|
|||
# - libc/net/getnet{ent,namadr}.c, netdb.h: remove __n_pad0
|
||||
#
|
||||
major=12
|
||||
minor=137
|
||||
minor=138
|
||||
|
|
Loading…
Reference in New Issue