summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2001-03-28 21:05:26 +1000
committerDamien Miller <djm@mindrot.org>2001-03-28 21:05:26 +1000
commitb68af624a9bf64fcf810a16a35749f4047ebe1ef (patch)
tree0a3467611968e1af5f3ca3d148d78699bd816aab
parent98344741512e0171567409c5c7208af5cebd4fe1 (diff)
- (djm) Sync openbsd-compat/glob.c
-rw-r--r--ChangeLog3
-rw-r--r--configure.in26
-rw-r--r--openbsd-compat/glob.c81
3 files changed, 52 insertions, 58 deletions
diff --git a/ChangeLog b/ChangeLog
index 6f7e8ae0a..1e138e87f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,7 @@
6 fix from Philippe Levan <levan@epix.net> 6 fix from Philippe Levan <levan@epix.net>
7 - (djm) Rework krbIV tests to get us closer to building on Redhat. Still 7 - (djm) Rework krbIV tests to get us closer to building on Redhat. Still
8 doesn't work because of conflicts between krbIV's and OpenSSL's des.h 8 doesn't work because of conflicts between krbIV's and OpenSSL's des.h
9 - (djm) Sync openbsd-compat/glob.c
9 10
1020010327 1120010327
11 - Attempt sync with sshlogin.c w/ OpenBSD (mainly CVS ID) 12 - Attempt sync with sshlogin.c w/ OpenBSD (mainly CVS ID)
@@ -4734,4 +4735,4 @@
4734 - Wrote replacements for strlcpy and mkdtemp 4735 - Wrote replacements for strlcpy and mkdtemp
4735 - Released 1.0pre1 4736 - Released 1.0pre1
4736 4737
4737$Id: ChangeLog,v 1.1024 2001/03/28 04:37:06 djm Exp $ 4738$Id: ChangeLog,v 1.1025 2001/03/28 11:05:26 djm Exp $
diff --git a/configure.in b/configure.in
index 256443a93..792e629c5 100644
--- a/configure.in
+++ b/configure.in
@@ -1,4 +1,4 @@
1# $Id: configure.in,v 1.270 2001/03/28 04:37:06 djm Exp $ 1# $Id: configure.in,v 1.271 2001/03/28 11:05:27 djm Exp $
2 2
3AC_INIT(ssh.c) 3AC_INIT(ssh.c)
4 4
@@ -595,22 +595,22 @@ AC_CACHE_CHECK([for OpenSSL directory], ac_cv_openssldir, [
595 # Try to use $ssldir/lib if it exists, otherwise 595 # Try to use $ssldir/lib if it exists, otherwise
596 # $ssldir 596 # $ssldir
597 if test -d "$ssldir/lib" ; then 597 if test -d "$ssldir/lib" ; then
598 LDFLAGS="$saved_LDFLAGS -L$ssldir/lib" 598 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
599 if test ! -z "$need_dash_r" ; then 599 if test ! -z "$need_dash_r" ; then
600 LDFLAGS="$LDFLAGS -R$ssldir/lib" 600 LDFLAGS="-R$ssldir/lib $LDFLAGS"
601 fi 601 fi
602 else 602 else
603 LDFLAGS="$saved_LDFLAGS -L$ssldir" 603 LDFLAGS="-L$ssldir $saved_LDFLAGS"
604 if test ! -z "$need_dash_r" ; then 604 if test ! -z "$need_dash_r" ; then
605 LDFLAGS="$LDFLAGS -R$ssldir" 605 LDFLAGS="-R$ssldir $LDFLAGS"
606 fi 606 fi
607 fi 607 fi
608 # Try to use $ssldir/include if it exists, otherwise 608 # Try to use $ssldir/include if it exists, otherwise
609 # $ssldir 609 # $ssldir
610 if test -d "$ssldir/include" ; then 610 if test -d "$ssldir/include" ; then
611 CPPFLAGS="$saved_CPPFLAGS -I$ssldir/include" 611 CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
612 else 612 else
613 CPPFLAGS="$saved_CPPFLAGS -I$ssldir" 613 CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
614 fi 614 fi
615 fi 615 fi
616 616
@@ -657,22 +657,22 @@ if (test ! -z "$ac_cv_openssldir" && test "x$ac_cv_openssldir" != "x(system)") ;
657 # Try to use $ssldir/lib if it exists, otherwise 657 # Try to use $ssldir/lib if it exists, otherwise
658 # $ssldir 658 # $ssldir
659 if test -d "$ssldir/lib" ; then 659 if test -d "$ssldir/lib" ; then
660 LDFLAGS="$saved_LDFLAGS -L$ssldir/lib" 660 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
661 if test ! -z "$need_dash_r" ; then 661 if test ! -z "$need_dash_r" ; then
662 LDFLAGS="$LDFLAGS -R$ssldir/lib" 662 LDFLAGS="-R$ssldir/lib $LDFLAGS"
663 fi 663 fi
664 else 664 else
665 LDFLAGS="$saved_LDFLAGS -L$ssldir" 665 LDFLAGS="-L$ssldir $saved_LDFLAGS"
666 if test ! -z "$need_dash_r" ; then 666 if test ! -z "$need_dash_r" ; then
667 LDFLAGS="$LDFLAGS -R$ssldir" 667 LDFLAGS="-R$ssldir $LDFLAGS"
668 fi 668 fi
669 fi 669 fi
670 # Try to use $ssldir/include if it exists, otherwise 670 # Try to use $ssldir/include if it exists, otherwise
671 # $ssldir 671 # $ssldir
672 if test -d "$ssldir/include" ; then 672 if test -d "$ssldir/include" ; then
673 CPPFLAGS="$saved_CPPFLAGS -I$ssldir/include" 673 CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
674 else 674 else
675 CPPFLAGS="$saved_CPPFLAGS -I$ssldir" 675 CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
676 fi 676 fi
677 fi 677 fi
678fi 678fi
diff --git a/openbsd-compat/glob.c b/openbsd-compat/glob.c
index 5ed286211..cca819de0 100644
--- a/openbsd-compat/glob.c
+++ b/openbsd-compat/glob.c
@@ -56,7 +56,7 @@ get_arg_max()
56#if 0 56#if 0
57static char sccsid[] = "@(#)glob.c 8.3 (Berkeley) 10/13/93"; 57static char sccsid[] = "@(#)glob.c 8.3 (Berkeley) 10/13/93";
58#else 58#else
59static char rcsid[] = "$OpenBSD: glob.c,v 1.10 2001/03/19 13:45:30 millert Exp $"; 59static char rcsid[] = "$OpenBSD: glob.c,v 1.13 2001/03/28 08:00:00 deraadt Exp $";
60#endif 60#endif
61#endif /* LIBC_SCCS and not lint */ 61#endif /* LIBC_SCCS and not lint */
62 62
@@ -137,13 +137,10 @@ typedef char Char;
137 137
138 138
139static int compare __P((const void *, const void *)); 139static int compare __P((const void *, const void *));
140static void g_Ctoc __P((const Char *, char *)); 140static int g_Ctoc __P((const Char *, char *, char *));
141static int g_lstat __P((Char *, struct stat *, glob_t *)); 141static int g_lstat __P((Char *, struct stat *, glob_t *));
142static DIR *g_opendir __P((Char *, glob_t *)); 142static DIR *g_opendir __P((Char *, glob_t *));
143static Char *g_strchr __P((Char *, int)); 143static Char *g_strchr __P((Char *, int));
144#ifdef notdef
145static Char *g_strcat __P((Char *, const Char *));
146#endif
147static int g_stat __P((Char *, struct stat *, glob_t *)); 144static int g_stat __P((Char *, struct stat *, glob_t *));
148static int glob0 __P((const Char *, glob_t *)); 145static int glob0 __P((const Char *, glob_t *));
149static int glob1 __P((Char *, glob_t *, size_t *)); 146static int glob1 __P((Char *, glob_t *, size_t *));
@@ -184,8 +181,8 @@ glob(pattern, flags, errfunc, pglob)
184 bufnext = patbuf; 181 bufnext = patbuf;
185 bufend = bufnext + MAXPATHLEN; 182 bufend = bufnext + MAXPATHLEN;
186 if (flags & GLOB_NOESCAPE) 183 if (flags & GLOB_NOESCAPE)
187 while (bufnext < bufend && (c = *patnext++) != EOS) 184 while (bufnext < bufend && (c = *patnext++) != EOS)
188 *bufnext++ = c; 185 *bufnext++ = c;
189 else { 186 else {
190 /* Protect the quoted characters. */ 187 /* Protect the quoted characters. */
191 while (bufnext < bufend && (c = *patnext++) != EOS) 188 while (bufnext < bufend && (c = *patnext++) != EOS)
@@ -279,7 +276,7 @@ static int globexp2(ptr, pattern, pglob, rv)
279 return 0; 276 return 0;
280 } 277 }
281 278
282 for (i = 0, pl = pm = ptr; pm <= pe; pm++) 279 for (i = 0, pl = pm = ptr; pm <= pe; pm++) {
283 switch (*pm) { 280 switch (*pm) {
284 case LBRACKET: 281 case LBRACKET:
285 /* Ignore everything between [] */ 282 /* Ignore everything between [] */
@@ -300,8 +297,8 @@ static int globexp2(ptr, pattern, pglob, rv)
300 297
301 case RBRACE: 298 case RBRACE:
302 if (i) { 299 if (i) {
303 i--; 300 i--;
304 break; 301 break;
305 } 302 }
306 /* FALLTHROUGH */ 303 /* FALLTHROUGH */
307 case COMMA: 304 case COMMA:
@@ -332,6 +329,7 @@ static int globexp2(ptr, pattern, pglob, rv)
332 default: 329 default:
333 break; 330 break;
334 } 331 }
332 }
335 *rv = 0; 333 *rv = 0;
336 return 0; 334 return 0;
337} 335}
@@ -464,7 +462,7 @@ glob0(pattern, pglob)
464 * to avoid exponential behavior 462 * to avoid exponential behavior
465 */ 463 */
466 if (bufnext == patbuf || bufnext[-1] != M_ALL) 464 if (bufnext == patbuf || bufnext[-1] != M_ALL)
467 *bufnext++ = M_ALL; 465 *bufnext++ = M_ALL;
468 break; 466 break;
469 default: 467 default:
470 *bufnext++ = CHAR(c); 468 *bufnext++ = CHAR(c);
@@ -546,8 +544,8 @@ glob2(pathbuf, pathend, pattern, pglob, limitp)
546 return(0); 544 return(0);
547 545
548 if (((pglob->gl_flags & GLOB_MARK) && 546 if (((pglob->gl_flags & GLOB_MARK) &&
549 pathend[-1] != SEP) && (S_ISDIR(sb.st_mode) 547 pathend[-1] != SEP) && (S_ISDIR(sb.st_mode) ||
550 || (S_ISLNK(sb.st_mode) && 548 (S_ISLNK(sb.st_mode) &&
551 (g_stat(pathbuf, &sb, pglob) == 0) && 549 (g_stat(pathbuf, &sb, pglob) == 0) &&
552 S_ISDIR(sb.st_mode)))) { 550 S_ISDIR(sb.st_mode)))) {
553 *pathend++ = SEP; 551 *pathend++ = SEP;
@@ -571,7 +569,8 @@ glob2(pathbuf, pathend, pattern, pglob, limitp)
571 pattern = p; 569 pattern = p;
572 while (*pattern == SEP) 570 while (*pattern == SEP)
573 *pathend++ = *pattern++; 571 *pathend++ = *pattern++;
574 } else /* Need expansion, recurse. */ 572 } else
573 /* Need expansion, recurse. */
575 return(glob3(pathbuf, pathend, pattern, p, pglob, 574 return(glob3(pathbuf, pathend, pattern, p, pglob,
576 limitp)); 575 limitp));
577 } 576 }
@@ -603,10 +602,11 @@ glob3(pathbuf, pathend, pattern, restpattern, pglob, limitp)
603 if ((dirp = g_opendir(pathbuf, pglob)) == NULL) { 602 if ((dirp = g_opendir(pathbuf, pglob)) == NULL) {
604 /* TODO: don't call for ENOENT or ENOTDIR? */ 603 /* TODO: don't call for ENOENT or ENOTDIR? */
605 if (pglob->gl_errfunc) { 604 if (pglob->gl_errfunc) {
606 g_Ctoc(pathbuf, buf); 605 if (g_Ctoc(pathbuf, buf, buf+sizeof(buf)))
606 return(GLOB_ABORTED);
607 if (pglob->gl_errfunc(buf, errno) || 607 if (pglob->gl_errfunc(buf, errno) ||
608 pglob->gl_flags & GLOB_ERR) 608 pglob->gl_flags & GLOB_ERR)
609 return (GLOB_ABORTED); 609 return(GLOB_ABORTED);
610 } 610 }
611 return(0); 611 return(0);
612 } 612 }
@@ -695,7 +695,10 @@ globextend(path, pglob, limitp)
695 len = (size_t)(p - path); 695 len = (size_t)(p - path);
696 *limitp += len; 696 *limitp += len;
697 if ((copy = malloc(len)) != NULL) { 697 if ((copy = malloc(len)) != NULL) {
698 g_Ctoc(path, copy); 698 if (g_Ctoc(path, copy, copy+len+1)) {
699 free(copy);
700 return(GLOB_NOSPACE);
701 }
699 pathv[pglob->gl_offs + pglob->gl_pathc++] = copy; 702 pathv[pglob->gl_offs + pglob->gl_pathc++] = copy;
700 } 703 }
701 pathv[pglob->gl_offs + pglob->gl_pathc] = NULL; 704 pathv[pglob->gl_offs + pglob->gl_pathc] = NULL;
@@ -730,7 +733,8 @@ match(name, pat, patend)
730 do 733 do
731 if (match(name, pat, patend)) 734 if (match(name, pat, patend))
732 return(1); 735 return(1);
733 while (*name++ != EOS); 736 while (*name++ != EOS)
737 ;
734 return(0); 738 return(0);
735 case M_ONE: 739 case M_ONE:
736 if (*name++ == EOS) 740 if (*name++ == EOS)
@@ -788,8 +792,10 @@ g_opendir(str, pglob)
788 792
789 if (!*str) 793 if (!*str)
790 strcpy(buf, "."); 794 strcpy(buf, ".");
791 else 795 else {
792 g_Ctoc(str, buf); 796 if (g_Ctoc(str, buf, buf+sizeof(buf)))
797 return(NULL);
798 }
793 799
794 if (pglob->gl_flags & GLOB_ALTDIRFUNC) 800 if (pglob->gl_flags & GLOB_ALTDIRFUNC)
795 return((*pglob->gl_opendir)(buf)); 801 return((*pglob->gl_opendir)(buf));
@@ -805,7 +811,8 @@ g_lstat(fn, sb, pglob)
805{ 811{
806 char buf[MAXPATHLEN]; 812 char buf[MAXPATHLEN];
807 813
808 g_Ctoc(fn, buf); 814 if (g_Ctoc(fn, buf, buf+sizeof(buf)))
815 return(-1);
809 if (pglob->gl_flags & GLOB_ALTDIRFUNC) 816 if (pglob->gl_flags & GLOB_ALTDIRFUNC)
810 return((*pglob->gl_lstat)(buf, sb)); 817 return((*pglob->gl_lstat)(buf, sb));
811 return(lstat(buf, sb)); 818 return(lstat(buf, sb));
@@ -819,7 +826,8 @@ g_stat(fn, sb, pglob)
819{ 826{
820 char buf[MAXPATHLEN]; 827 char buf[MAXPATHLEN];
821 828
822 g_Ctoc(fn, buf); 829 if (g_Ctoc(fn, buf, buf+sizeof(buf)))
830 return(-1);
823 if (pglob->gl_flags & GLOB_ALTDIRFUNC) 831 if (pglob->gl_flags & GLOB_ALTDIRFUNC)
824 return((*pglob->gl_stat)(buf, sb)); 832 return((*pglob->gl_stat)(buf, sb));
825 return(stat(buf, sb)); 833 return(stat(buf, sb));
@@ -837,33 +845,18 @@ g_strchr(str, ch)
837 return (NULL); 845 return (NULL);
838} 846}
839 847
840#ifdef notdef 848static int
841static Char * 849g_Ctoc(str, buf, ebuf)
842g_strcat(dst, src)
843 Char *dst;
844 const Char* src;
845{
846 Char *sdst = dst;
847
848 while (*dst++)
849 continue;
850 --dst;
851 while((*dst++ = *src++) != EOS)
852 continue;
853
854 return (sdst);
855}
856#endif
857
858static void
859g_Ctoc(str, buf)
860 register const Char *str; 850 register const Char *str;
861 char *buf; 851 char *buf, *ebuf;
862{ 852{
863 register char *dc; 853 register char *dc;
864 854
865 for (dc = buf; (*dc++ = *str++) != EOS;) 855 for (dc = buf; dc < ebuf && (*dc++ = *str++) != EOS;)
866 continue; 856 continue;
857 if (dc >= ebuf)
858 return (1);
859 return (0);
867} 860}
868 861
869#ifdef DEBUG 862#ifdef DEBUG