- (djm) Sync openbsd-compat/glob.c
This commit is contained in:
parent
9834474151
commit
b68af624a9
|
@ -6,6 +6,7 @@
|
||||||
fix from Philippe Levan <levan@epix.net>
|
fix from Philippe Levan <levan@epix.net>
|
||||||
- (djm) Rework krbIV tests to get us closer to building on Redhat. Still
|
- (djm) Rework krbIV tests to get us closer to building on Redhat. Still
|
||||||
doesn't work because of conflicts between krbIV's and OpenSSL's des.h
|
doesn't work because of conflicts between krbIV's and OpenSSL's des.h
|
||||||
|
- (djm) Sync openbsd-compat/glob.c
|
||||||
|
|
||||||
20010327
|
20010327
|
||||||
- Attempt sync with sshlogin.c w/ OpenBSD (mainly CVS ID)
|
- Attempt sync with sshlogin.c w/ OpenBSD (mainly CVS ID)
|
||||||
|
@ -4734,4 +4735,4 @@
|
||||||
- Wrote replacements for strlcpy and mkdtemp
|
- Wrote replacements for strlcpy and mkdtemp
|
||||||
- Released 1.0pre1
|
- Released 1.0pre1
|
||||||
|
|
||||||
$Id: ChangeLog,v 1.1024 2001/03/28 04:37:06 djm Exp $
|
$Id: ChangeLog,v 1.1025 2001/03/28 11:05:26 djm Exp $
|
||||||
|
|
26
configure.in
26
configure.in
|
@ -1,4 +1,4 @@
|
||||||
# $Id: configure.in,v 1.270 2001/03/28 04:37:06 djm Exp $
|
# $Id: configure.in,v 1.271 2001/03/28 11:05:27 djm Exp $
|
||||||
|
|
||||||
AC_INIT(ssh.c)
|
AC_INIT(ssh.c)
|
||||||
|
|
||||||
|
@ -595,22 +595,22 @@ AC_CACHE_CHECK([for OpenSSL directory], ac_cv_openssldir, [
|
||||||
# Try to use $ssldir/lib if it exists, otherwise
|
# Try to use $ssldir/lib if it exists, otherwise
|
||||||
# $ssldir
|
# $ssldir
|
||||||
if test -d "$ssldir/lib" ; then
|
if test -d "$ssldir/lib" ; then
|
||||||
LDFLAGS="$saved_LDFLAGS -L$ssldir/lib"
|
LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
|
||||||
if test ! -z "$need_dash_r" ; then
|
if test ! -z "$need_dash_r" ; then
|
||||||
LDFLAGS="$LDFLAGS -R$ssldir/lib"
|
LDFLAGS="-R$ssldir/lib $LDFLAGS"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
LDFLAGS="$saved_LDFLAGS -L$ssldir"
|
LDFLAGS="-L$ssldir $saved_LDFLAGS"
|
||||||
if test ! -z "$need_dash_r" ; then
|
if test ! -z "$need_dash_r" ; then
|
||||||
LDFLAGS="$LDFLAGS -R$ssldir"
|
LDFLAGS="-R$ssldir $LDFLAGS"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
# Try to use $ssldir/include if it exists, otherwise
|
# Try to use $ssldir/include if it exists, otherwise
|
||||||
# $ssldir
|
# $ssldir
|
||||||
if test -d "$ssldir/include" ; then
|
if test -d "$ssldir/include" ; then
|
||||||
CPPFLAGS="$saved_CPPFLAGS -I$ssldir/include"
|
CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
|
||||||
else
|
else
|
||||||
CPPFLAGS="$saved_CPPFLAGS -I$ssldir"
|
CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -657,22 +657,22 @@ if (test ! -z "$ac_cv_openssldir" && test "x$ac_cv_openssldir" != "x(system)") ;
|
||||||
# Try to use $ssldir/lib if it exists, otherwise
|
# Try to use $ssldir/lib if it exists, otherwise
|
||||||
# $ssldir
|
# $ssldir
|
||||||
if test -d "$ssldir/lib" ; then
|
if test -d "$ssldir/lib" ; then
|
||||||
LDFLAGS="$saved_LDFLAGS -L$ssldir/lib"
|
LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
|
||||||
if test ! -z "$need_dash_r" ; then
|
if test ! -z "$need_dash_r" ; then
|
||||||
LDFLAGS="$LDFLAGS -R$ssldir/lib"
|
LDFLAGS="-R$ssldir/lib $LDFLAGS"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
LDFLAGS="$saved_LDFLAGS -L$ssldir"
|
LDFLAGS="-L$ssldir $saved_LDFLAGS"
|
||||||
if test ! -z "$need_dash_r" ; then
|
if test ! -z "$need_dash_r" ; then
|
||||||
LDFLAGS="$LDFLAGS -R$ssldir"
|
LDFLAGS="-R$ssldir $LDFLAGS"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
# Try to use $ssldir/include if it exists, otherwise
|
# Try to use $ssldir/include if it exists, otherwise
|
||||||
# $ssldir
|
# $ssldir
|
||||||
if test -d "$ssldir/include" ; then
|
if test -d "$ssldir/include" ; then
|
||||||
CPPFLAGS="$saved_CPPFLAGS -I$ssldir/include"
|
CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
|
||||||
else
|
else
|
||||||
CPPFLAGS="$saved_CPPFLAGS -I$ssldir"
|
CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -56,7 +56,7 @@ get_arg_max()
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)glob.c 8.3 (Berkeley) 10/13/93";
|
static char sccsid[] = "@(#)glob.c 8.3 (Berkeley) 10/13/93";
|
||||||
#else
|
#else
|
||||||
static char rcsid[] = "$OpenBSD: glob.c,v 1.10 2001/03/19 13:45:30 millert Exp $";
|
static char rcsid[] = "$OpenBSD: glob.c,v 1.13 2001/03/28 08:00:00 deraadt Exp $";
|
||||||
#endif
|
#endif
|
||||||
#endif /* LIBC_SCCS and not lint */
|
#endif /* LIBC_SCCS and not lint */
|
||||||
|
|
||||||
|
@ -137,13 +137,10 @@ typedef char Char;
|
||||||
|
|
||||||
|
|
||||||
static int compare __P((const void *, const void *));
|
static int compare __P((const void *, const void *));
|
||||||
static void g_Ctoc __P((const Char *, char *));
|
static int g_Ctoc __P((const Char *, char *, char *));
|
||||||
static int g_lstat __P((Char *, struct stat *, glob_t *));
|
static int g_lstat __P((Char *, struct stat *, glob_t *));
|
||||||
static DIR *g_opendir __P((Char *, glob_t *));
|
static DIR *g_opendir __P((Char *, glob_t *));
|
||||||
static Char *g_strchr __P((Char *, int));
|
static Char *g_strchr __P((Char *, int));
|
||||||
#ifdef notdef
|
|
||||||
static Char *g_strcat __P((Char *, const Char *));
|
|
||||||
#endif
|
|
||||||
static int g_stat __P((Char *, struct stat *, glob_t *));
|
static int g_stat __P((Char *, struct stat *, glob_t *));
|
||||||
static int glob0 __P((const Char *, glob_t *));
|
static int glob0 __P((const Char *, glob_t *));
|
||||||
static int glob1 __P((Char *, glob_t *, size_t *));
|
static int glob1 __P((Char *, glob_t *, size_t *));
|
||||||
|
@ -279,7 +276,7 @@ static int globexp2(ptr, pattern, pglob, rv)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0, pl = pm = ptr; pm <= pe; pm++)
|
for (i = 0, pl = pm = ptr; pm <= pe; pm++) {
|
||||||
switch (*pm) {
|
switch (*pm) {
|
||||||
case LBRACKET:
|
case LBRACKET:
|
||||||
/* Ignore everything between [] */
|
/* Ignore everything between [] */
|
||||||
|
@ -332,6 +329,7 @@ static int globexp2(ptr, pattern, pglob, rv)
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
*rv = 0;
|
*rv = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -546,8 +544,8 @@ glob2(pathbuf, pathend, pattern, pglob, limitp)
|
||||||
return(0);
|
return(0);
|
||||||
|
|
||||||
if (((pglob->gl_flags & GLOB_MARK) &&
|
if (((pglob->gl_flags & GLOB_MARK) &&
|
||||||
pathend[-1] != SEP) && (S_ISDIR(sb.st_mode)
|
pathend[-1] != SEP) && (S_ISDIR(sb.st_mode) ||
|
||||||
|| (S_ISLNK(sb.st_mode) &&
|
(S_ISLNK(sb.st_mode) &&
|
||||||
(g_stat(pathbuf, &sb, pglob) == 0) &&
|
(g_stat(pathbuf, &sb, pglob) == 0) &&
|
||||||
S_ISDIR(sb.st_mode)))) {
|
S_ISDIR(sb.st_mode)))) {
|
||||||
*pathend++ = SEP;
|
*pathend++ = SEP;
|
||||||
|
@ -571,7 +569,8 @@ glob2(pathbuf, pathend, pattern, pglob, limitp)
|
||||||
pattern = p;
|
pattern = p;
|
||||||
while (*pattern == SEP)
|
while (*pattern == SEP)
|
||||||
*pathend++ = *pattern++;
|
*pathend++ = *pattern++;
|
||||||
} else /* Need expansion, recurse. */
|
} else
|
||||||
|
/* Need expansion, recurse. */
|
||||||
return(glob3(pathbuf, pathend, pattern, p, pglob,
|
return(glob3(pathbuf, pathend, pattern, p, pglob,
|
||||||
limitp));
|
limitp));
|
||||||
}
|
}
|
||||||
|
@ -603,7 +602,8 @@ glob3(pathbuf, pathend, pattern, restpattern, pglob, limitp)
|
||||||
if ((dirp = g_opendir(pathbuf, pglob)) == NULL) {
|
if ((dirp = g_opendir(pathbuf, pglob)) == NULL) {
|
||||||
/* TODO: don't call for ENOENT or ENOTDIR? */
|
/* TODO: don't call for ENOENT or ENOTDIR? */
|
||||||
if (pglob->gl_errfunc) {
|
if (pglob->gl_errfunc) {
|
||||||
g_Ctoc(pathbuf, buf);
|
if (g_Ctoc(pathbuf, buf, buf+sizeof(buf)))
|
||||||
|
return(GLOB_ABORTED);
|
||||||
if (pglob->gl_errfunc(buf, errno) ||
|
if (pglob->gl_errfunc(buf, errno) ||
|
||||||
pglob->gl_flags & GLOB_ERR)
|
pglob->gl_flags & GLOB_ERR)
|
||||||
return(GLOB_ABORTED);
|
return(GLOB_ABORTED);
|
||||||
|
@ -695,7 +695,10 @@ globextend(path, pglob, limitp)
|
||||||
len = (size_t)(p - path);
|
len = (size_t)(p - path);
|
||||||
*limitp += len;
|
*limitp += len;
|
||||||
if ((copy = malloc(len)) != NULL) {
|
if ((copy = malloc(len)) != NULL) {
|
||||||
g_Ctoc(path, copy);
|
if (g_Ctoc(path, copy, copy+len+1)) {
|
||||||
|
free(copy);
|
||||||
|
return(GLOB_NOSPACE);
|
||||||
|
}
|
||||||
pathv[pglob->gl_offs + pglob->gl_pathc++] = copy;
|
pathv[pglob->gl_offs + pglob->gl_pathc++] = copy;
|
||||||
}
|
}
|
||||||
pathv[pglob->gl_offs + pglob->gl_pathc] = NULL;
|
pathv[pglob->gl_offs + pglob->gl_pathc] = NULL;
|
||||||
|
@ -730,7 +733,8 @@ match(name, pat, patend)
|
||||||
do
|
do
|
||||||
if (match(name, pat, patend))
|
if (match(name, pat, patend))
|
||||||
return(1);
|
return(1);
|
||||||
while (*name++ != EOS);
|
while (*name++ != EOS)
|
||||||
|
;
|
||||||
return(0);
|
return(0);
|
||||||
case M_ONE:
|
case M_ONE:
|
||||||
if (*name++ == EOS)
|
if (*name++ == EOS)
|
||||||
|
@ -788,8 +792,10 @@ g_opendir(str, pglob)
|
||||||
|
|
||||||
if (!*str)
|
if (!*str)
|
||||||
strcpy(buf, ".");
|
strcpy(buf, ".");
|
||||||
else
|
else {
|
||||||
g_Ctoc(str, buf);
|
if (g_Ctoc(str, buf, buf+sizeof(buf)))
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
if (pglob->gl_flags & GLOB_ALTDIRFUNC)
|
if (pglob->gl_flags & GLOB_ALTDIRFUNC)
|
||||||
return((*pglob->gl_opendir)(buf));
|
return((*pglob->gl_opendir)(buf));
|
||||||
|
@ -805,7 +811,8 @@ g_lstat(fn, sb, pglob)
|
||||||
{
|
{
|
||||||
char buf[MAXPATHLEN];
|
char buf[MAXPATHLEN];
|
||||||
|
|
||||||
g_Ctoc(fn, buf);
|
if (g_Ctoc(fn, buf, buf+sizeof(buf)))
|
||||||
|
return(-1);
|
||||||
if (pglob->gl_flags & GLOB_ALTDIRFUNC)
|
if (pglob->gl_flags & GLOB_ALTDIRFUNC)
|
||||||
return((*pglob->gl_lstat)(buf, sb));
|
return((*pglob->gl_lstat)(buf, sb));
|
||||||
return(lstat(buf, sb));
|
return(lstat(buf, sb));
|
||||||
|
@ -819,7 +826,8 @@ g_stat(fn, sb, pglob)
|
||||||
{
|
{
|
||||||
char buf[MAXPATHLEN];
|
char buf[MAXPATHLEN];
|
||||||
|
|
||||||
g_Ctoc(fn, buf);
|
if (g_Ctoc(fn, buf, buf+sizeof(buf)))
|
||||||
|
return(-1);
|
||||||
if (pglob->gl_flags & GLOB_ALTDIRFUNC)
|
if (pglob->gl_flags & GLOB_ALTDIRFUNC)
|
||||||
return((*pglob->gl_stat)(buf, sb));
|
return((*pglob->gl_stat)(buf, sb));
|
||||||
return(stat(buf, sb));
|
return(stat(buf, sb));
|
||||||
|
@ -837,33 +845,18 @@ g_strchr(str, ch)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef notdef
|
static int
|
||||||
static Char *
|
g_Ctoc(str, buf, ebuf)
|
||||||
g_strcat(dst, src)
|
|
||||||
Char *dst;
|
|
||||||
const Char* src;
|
|
||||||
{
|
|
||||||
Char *sdst = dst;
|
|
||||||
|
|
||||||
while (*dst++)
|
|
||||||
continue;
|
|
||||||
--dst;
|
|
||||||
while((*dst++ = *src++) != EOS)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
return (sdst);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void
|
|
||||||
g_Ctoc(str, buf)
|
|
||||||
register const Char *str;
|
register const Char *str;
|
||||||
char *buf;
|
char *buf, *ebuf;
|
||||||
{
|
{
|
||||||
register char *dc;
|
register char *dc;
|
||||||
|
|
||||||
for (dc = buf; (*dc++ = *str++) != EOS;)
|
for (dc = buf; dc < ebuf && (*dc++ = *str++) != EOS;)
|
||||||
continue;
|
continue;
|
||||||
|
if (dc >= ebuf)
|
||||||
|
return (1);
|
||||||
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|
Loading…
Reference in New Issue