View | Details | Raw Unified | Return to bug 2463 | Differences between
and this patch

Collapse All | Expand All

(-)a/includes.h (-6 lines)
Lines 32-43 Link Here
32
#ifdef HAVE_BSTRING_H
32
#ifdef HAVE_BSTRING_H
33
# include <bstring.h>
33
# include <bstring.h>
34
#endif
34
#endif
35
#if defined(HAVE_GLOB_H) && defined(GLOB_HAS_ALTDIRFUNC) && \
36
    defined(GLOB_HAS_GL_MATCHC) && defined(GLOB_HAS_GL_STATV) && \
37
    defined(HAVE_DECL_GLOB_NOMATCH) &&  HAVE_DECL_GLOB_NOMATCH != 0 && \
38
    !defined(BROKEN_GLOB)
39
# include <glob.h>
40
#endif
41
#ifdef HAVE_ENDIAN_H
35
#ifdef HAVE_ENDIAN_H
42
# include <endian.h>
36
# include <endian.h>
43
#endif
37
#endif
(-)a/openbsd-compat/glob.c (-25 / +26 lines)
Lines 59-64 Link Here
59
 */
59
 */
60
60
61
#include "includes.h"
61
#include "includes.h"
62
#include "glob.h"
62
63
63
#include <sys/types.h>
64
#include <sys/types.h>
64
#include <sys/stat.h>
65
#include <sys/stat.h>
Lines 150-172 struct glob_path_stat { Link Here
150
static int	 compare(const void *, const void *);
151
static int	 compare(const void *, const void *);
151
static int	 compare_gps(const void *, const void *);
152
static int	 compare_gps(const void *, const void *);
152
static int	 g_Ctoc(const Char *, char *, u_int);
153
static int	 g_Ctoc(const Char *, char *, u_int);
153
static int	 g_lstat(Char *, struct stat *, glob_t *);
154
static int	 g_lstat(Char *, struct stat *, compat_glob_t *);
154
static DIR	*g_opendir(Char *, glob_t *);
155
static DIR	*g_opendir(Char *, compat_glob_t *);
155
static Char	*g_strchr(const Char *, int);
156
static Char	*g_strchr(const Char *, int);
156
static int	 g_strncmp(const Char *, const char *, size_t);
157
static int	 g_strncmp(const Char *, const char *, size_t);
157
static int	 g_stat(Char *, struct stat *, glob_t *);
158
static int	 g_stat(Char *, struct stat *, compat_glob_t *);
158
static int	 glob0(const Char *, glob_t *, struct glob_lim *);
159
static int	 glob0(const Char *, compat_glob_t *, struct glob_lim *);
159
static int	 glob1(Char *, Char *, glob_t *, struct glob_lim *);
160
static int	 glob1(Char *, Char *, compat_glob_t *, struct glob_lim *);
160
static int	 glob2(Char *, Char *, Char *, Char *, Char *, Char *,
161
static int	 glob2(Char *, Char *, Char *, Char *, Char *, Char *,
161
		    glob_t *, struct glob_lim *);
162
		    compat_glob_t *, struct glob_lim *);
162
static int	 glob3(Char *, Char *, Char *, Char *, Char *,
163
static int	 glob3(Char *, Char *, Char *, Char *, Char *,
163
		    Char *, Char *, glob_t *, struct glob_lim *);
164
		    Char *, Char *, compat_glob_t *, struct glob_lim *);
164
static int	 globextend(const Char *, glob_t *, struct glob_lim *,
165
static int	 globextend(const Char *, compat_glob_t *, struct glob_lim *,
165
		    struct stat *);
166
		    struct stat *);
166
static const Char *
167
static const Char *
167
		 globtilde(const Char *, Char *, size_t, glob_t *);
168
		 globtilde(const Char *, Char *, size_t, compat_glob_t *);
168
static int	 globexp1(const Char *, glob_t *, struct glob_lim *);
169
static int	 globexp1(const Char *, compat_glob_t *, struct glob_lim *);
169
static int	 globexp2(const Char *, const Char *, glob_t *,
170
static int	 globexp2(const Char *, const Char *, compat_glob_t *,
170
		    struct glob_lim *);
171
		    struct glob_lim *);
171
static int	 match(Char *, Char *, Char *, int);
172
static int	 match(Char *, Char *, Char *, int);
172
#ifdef DEBUG
173
#ifdef DEBUG
Lines 174-181 static void qprintf(const char *, Char *); Link Here
174
#endif
175
#endif
175
176
176
int
177
int
177
glob(const char *pattern, int flags, int (*errfunc)(const char *, int),
178
__compat_glob(const char *pattern, int flags, int (*errfunc)(const char *, int),
178
    glob_t *pglob)
179
    compat_glob_t *pglob)
179
{
180
{
180
	const u_char *patnext;
181
	const u_char *patnext;
181
	int c;
182
	int c;
Lines 233-239 glob(const char *pattern, int flags, int (*errfunc)(const char *, int), Link Here
233
 * characters
234
 * characters
234
 */
235
 */
235
static int
236
static int
236
globexp1(const Char *pattern, glob_t *pglob, struct glob_lim *limitp)
237
globexp1(const Char *pattern, compat_glob_t *pglob, struct glob_lim *limitp)
237
{
238
{
238
	const Char* ptr = pattern;
239
	const Char* ptr = pattern;
239
240
Lines 254-260 globexp1(const Char *pattern, glob_t *pglob, struct glob_lim *limitp) Link Here
254
 * If it fails then it tries to glob the rest of the pattern and returns.
255
 * If it fails then it tries to glob the rest of the pattern and returns.
255
 */
256
 */
256
static int
257
static int
257
globexp2(const Char *ptr, const Char *pattern, glob_t *pglob,
258
globexp2(const Char *ptr, const Char *pattern, compat_glob_t *pglob,
258
    struct glob_lim *limitp)
259
    struct glob_lim *limitp)
259
{
260
{
260
	int     i, rv;
261
	int     i, rv;
Lines 359-365 globexp2(const Char *ptr, const Char *pattern, glob_t *pglob, Link Here
359
 * expand tilde from the passwd file.
360
 * expand tilde from the passwd file.
360
 */
361
 */
361
static const Char *
362
static const Char *
362
globtilde(const Char *pattern, Char *patbuf, size_t patbuf_len, glob_t *pglob)
363
globtilde(const Char *pattern, Char *patbuf, size_t patbuf_len, compat_glob_t *pglob)
363
{
364
{
364
	struct passwd *pwd;
365
	struct passwd *pwd;
365
	char *h;
366
	char *h;
Lines 468-474 g_charclass(const Char **patternp, Char **bufnextp) Link Here
468
 * to find no matches.
469
 * to find no matches.
469
 */
470
 */
470
static int
471
static int
471
glob0(const Char *pattern, glob_t *pglob, struct glob_lim *limitp)
472
glob0(const Char *pattern, compat_glob_t *pglob, struct glob_lim *limitp)
472
{
473
{
473
	const Char *qpatnext;
474
	const Char *qpatnext;
474
	int c, err, oldpathc;
475
	int c, err, oldpathc;
Lines 606-612 compare_gps(const void *_p, const void *_q) Link Here
606
}
607
}
607
608
608
static int
609
static int
609
glob1(Char *pattern, Char *pattern_last, glob_t *pglob, struct glob_lim *limitp)
610
glob1(Char *pattern, Char *pattern_last, compat_glob_t *pglob, struct glob_lim *limitp)
610
{
611
{
611
	Char pathbuf[MAXPATHLEN];
612
	Char pathbuf[MAXPATHLEN];
612
613
Lines 625-631 glob1(Char *pattern, Char *pattern_last, glob_t *pglob, struct glob_lim *limitp) Link Here
625
 */
626
 */
626
static int
627
static int
627
glob2(Char *pathbuf, Char *pathbuf_last, Char *pathend, Char *pathend_last,
628
glob2(Char *pathbuf, Char *pathbuf_last, Char *pathend, Char *pathend_last,
628
    Char *pattern, Char *pattern_last, glob_t *pglob, struct glob_lim *limitp)
629
    Char *pattern, Char *pattern_last, compat_glob_t *pglob, struct glob_lim *limitp)
629
{
630
{
630
	struct stat sb;
631
	struct stat sb;
631
	Char *p, *q;
632
	Char *p, *q;
Lines 693-699 glob2(Char *pathbuf, Char *pathbuf_last, Char *pathend, Char *pathend_last, Link Here
693
694
694
static int
695
static int
695
glob3(Char *pathbuf, Char *pathbuf_last, Char *pathend, Char *pathend_last,
696
glob3(Char *pathbuf, Char *pathbuf_last, Char *pathend, Char *pathend_last,
696
    Char *pattern, Char *restpattern, Char *restpattern_last, glob_t *pglob,
697
    Char *pattern, Char *restpattern, Char *restpattern_last, compat_glob_t *pglob,
697
    struct glob_lim *limitp)
698
    struct glob_lim *limitp)
698
{
699
{
699
	struct dirent *dp;
700
	struct dirent *dp;
Lines 792-798 glob3(Char *pathbuf, Char *pathbuf_last, Char *pathend, Char *pathend_last, Link Here
792
 *	gl_pathv points to (gl_offs + gl_pathc + 1) items.
793
 *	gl_pathv points to (gl_offs + gl_pathc + 1) items.
793
 */
794
 */
794
static int
795
static int
795
globextend(const Char *path, glob_t *pglob, struct glob_lim *limitp,
796
globextend(const Char *path, compat_glob_t *pglob, struct glob_lim *limitp,
796
    struct stat *sb)
797
    struct stat *sb)
797
{
798
{
798
	char **pathv;
799
	char **pathv;
Lines 956-962 match(Char *name, Char *pat, Char *patend, int recur) Link Here
956
957
957
/* Free allocated data belonging to a glob_t structure. */
958
/* Free allocated data belonging to a glob_t structure. */
958
void
959
void
959
globfree(glob_t *pglob)
960
__compat_globfree(compat_glob_t *pglob)
960
{
961
{
961
	int i;
962
	int i;
962
	char **pp;
963
	char **pp;
Lines 980-986 globfree(glob_t *pglob) Link Here
980
}
981
}
981
982
982
static DIR *
983
static DIR *
983
g_opendir(Char *str, glob_t *pglob)
984
g_opendir(Char *str, compat_glob_t *pglob)
984
{
985
{
985
	char buf[MAXPATHLEN];
986
	char buf[MAXPATHLEN];
986
987
Lines 998-1004 g_opendir(Char *str, glob_t *pglob) Link Here
998
}
999
}
999
1000
1000
static int
1001
static int
1001
g_lstat(Char *fn, struct stat *sb, glob_t *pglob)
1002
g_lstat(Char *fn, struct stat *sb, compat_glob_t *pglob)
1002
{
1003
{
1003
	char buf[MAXPATHLEN];
1004
	char buf[MAXPATHLEN];
1004
1005
Lines 1010-1016 g_lstat(Char *fn, struct stat *sb, glob_t *pglob) Link Here
1010
}
1011
}
1011
1012
1012
static int
1013
static int
1013
g_stat(Char *fn, struct stat *sb, glob_t *pglob)
1014
g_stat(Char *fn, struct stat *sb, compat_glob_t *pglob)
1014
{
1015
{
1015
	char buf[MAXPATHLEN];
1016
	char buf[MAXPATHLEN];
1016
1017
(-)a/openbsd-compat/glob.h (-6 / +6 lines)
Lines 42-49 Link Here
42
    !defined(HAVE_DECL_GLOB_NOMATCH) || HAVE_DECL_GLOB_NOMATCH == 0 || \
42
    !defined(HAVE_DECL_GLOB_NOMATCH) || HAVE_DECL_GLOB_NOMATCH == 0 || \
43
    defined(BROKEN_GLOB)
43
    defined(BROKEN_GLOB)
44
44
45
#ifndef _GLOB_H_
45
#ifndef _COMPAT_GLOB_H_
46
#define	_GLOB_H_
46
#define	_COMPAT_GLOB_H_
47
47
48
#include <sys/stat.h>
48
#include <sys/stat.h>
49
49
Lines 68-74 typedef struct { Link Here
68
	void *(*gl_opendir)(const char *);
68
	void *(*gl_opendir)(const char *);
69
	int (*gl_lstat)(const char *, struct stat *);
69
	int (*gl_lstat)(const char *, struct stat *);
70
	int (*gl_stat)(const char *, struct stat *);
70
	int (*gl_stat)(const char *, struct stat *);
71
} glob_t;
71
} compat_glob_t;
72
72
73
#define	GLOB_APPEND	0x0001	/* Append to output from previous call. */
73
#define	GLOB_APPEND	0x0001	/* Append to output from previous call. */
74
#define	GLOB_DOOFFS	0x0002	/* Use gl_offs. */
74
#define	GLOB_DOOFFS	0x0002	/* Use gl_offs. */
Lines 93-102 typedef struct { Link Here
93
#define	GLOB_KEEPSTAT	0x4000	/* Retain stat data for paths in gl_statv. */
93
#define	GLOB_KEEPSTAT	0x4000	/* Retain stat data for paths in gl_statv. */
94
#define GLOB_ABEND	GLOB_ABORTED /* backward compatibility */
94
#define GLOB_ABEND	GLOB_ABORTED /* backward compatibility */
95
95
96
int	glob(const char *, int, int (*)(const char *, int), glob_t *);
96
int	__compat_glob(const char *, int, int (*)(const char *, int), compat_glob_t *);
97
void	globfree(glob_t *);
97
void	__compat_globfree(compat_glob_t *);
98
98
99
#endif /* !_GLOB_H_ */
99
#endif /* !_COMPAT_GLOB_H_ */
100
100
101
#endif /* !defined(HAVE_GLOB_H) || !defined(GLOB_HAS_ALTDIRFUNC)  ||
101
#endif /* !defined(HAVE_GLOB_H) || !defined(GLOB_HAS_ALTDIRFUNC)  ||
102
	  !defined(GLOB_HAS_GL_MATCHC) || !defined(GLOH_HAS_GL_STATV) */
102
	  !defined(GLOB_HAS_GL_MATCHC) || !defined(GLOH_HAS_GL_STATV) */
(-)a/openbsd-compat/openbsd-compat.h (-1 lines)
Lines 39-45 Link Here
39
/* OpenBSD function replacements */
39
/* OpenBSD function replacements */
40
#include "base64.h"
40
#include "base64.h"
41
#include "sigact.h"
41
#include "sigact.h"
42
#include "glob.h"
43
#include "readpassphrase.h"
42
#include "readpassphrase.h"
44
#include "vis.h"
43
#include "vis.h"
45
#include "getrrsetbyname.h"
44
#include "getrrsetbyname.h"
(-)a/sftp-client.h (-1 / +12 lines)
Lines 21-26 Link Here
21
#ifndef _SFTP_CLIENT_H
21
#ifndef _SFTP_CLIENT_H
22
#define _SFTP_CLIENT_H
22
#define _SFTP_CLIENT_H
23
23
24
#if defined(HAVE_GLOB_H) && defined(GLOB_HAS_ALTDIRFUNC) && \
25
    defined(GLOB_HAS_GL_MATCHC) && defined(GLOB_HAS_GL_STATV) && \
26
    defined(HAVE_DECL_GLOB_NOMATCH) &&  HAVE_DECL_GLOB_NOMATCH != 0 && \
27
    !defined(BROKEN_GLOB)
28
# include <glob.h>
29
#else
30
# include "openbsd-compat/glob.h"
31
# define glob_t compat_glob_t
32
# define glob(a, b, c, d)  __compat_glob((a), (b), (c), (d))
33
# define globfree(a)  __compat_globfree((a))
34
#endif
35
24
typedef struct SFTP_DIRENT SFTP_DIRENT;
36
typedef struct SFTP_DIRENT SFTP_DIRENT;
25
37
26
struct SFTP_DIRENT {
38
struct SFTP_DIRENT {
27
- 

Return to bug 2463