Bugzilla – Attachment 2707 Details for
Bug 2463
Conflict with openbsd compat glob() function in shared libraries
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
patch reworked as proposed
glob_compat.patch (text/plain), 9.44 KB, created by
Jakub Jelen
on 2015-09-16 22:16:04 AEST
(
hide
)
Description:
patch reworked as proposed
Filename:
MIME Type:
Creator:
Jakub Jelen
Created:
2015-09-16 22:16:04 AEST
Size:
9.44 KB
patch
obsolete
>From 415ab863afe2128b9352a95bf47ed3f1c394812b Mon Sep 17 00:00:00 2001 >From: Jakub Jelen <jjelen@redhat.com> >Date: Fri, 11 Sep 2015 16:26:10 +0200 >Subject: [PATCH] Compat glob() > >Rename compat functions and type from <glob.h> header so it will not colide with dynamically linked libraries and other useage in code. > >Also removes glob header from openbsd-compat bundle and include this one only to sftp-client.h, where is it required. >--- > includes.h | 6 ----- > openbsd-compat/glob.c | 51 +++++++++++++++++++++-------------------- > openbsd-compat/glob.h | 12 +++++----- > openbsd-compat/openbsd-compat.h | 1 - > sftp-client.h | 12 ++++++++++ > 5 files changed, 44 insertions(+), 38 deletions(-) > >diff --git a/includes.h b/includes.h >index 2893a54..497a038 100644 >--- a/includes.h >+++ b/includes.h >@@ -32,12 +32,6 @@ > #ifdef HAVE_BSTRING_H > # include <bstring.h> > #endif >-#if defined(HAVE_GLOB_H) && defined(GLOB_HAS_ALTDIRFUNC) && \ >- defined(GLOB_HAS_GL_MATCHC) && defined(GLOB_HAS_GL_STATV) && \ >- defined(HAVE_DECL_GLOB_NOMATCH) && HAVE_DECL_GLOB_NOMATCH != 0 && \ >- !defined(BROKEN_GLOB) >-# include <glob.h> >-#endif > #ifdef HAVE_ENDIAN_H > # include <endian.h> > #endif >diff --git a/openbsd-compat/glob.c b/openbsd-compat/glob.c >index 742b4b9..1ea373d 100644 >--- a/openbsd-compat/glob.c >+++ b/openbsd-compat/glob.c >@@ -59,6 +59,7 @@ > */ > > #include "includes.h" >+#include "glob.h" > > #include <sys/types.h> > #include <sys/stat.h> >@@ -150,23 +151,23 @@ struct glob_path_stat { > static int compare(const void *, const void *); > static int compare_gps(const void *, const void *); > static int g_Ctoc(const Char *, char *, u_int); >-static int g_lstat(Char *, struct stat *, glob_t *); >-static DIR *g_opendir(Char *, glob_t *); >+static int g_lstat(Char *, struct stat *, compat_glob_t *); >+static DIR *g_opendir(Char *, compat_glob_t *); > static Char *g_strchr(const Char *, int); > static int g_strncmp(const Char *, const char *, size_t); >-static int g_stat(Char *, struct stat *, glob_t *); >-static int glob0(const Char *, glob_t *, struct glob_lim *); >-static int glob1(Char *, Char *, glob_t *, struct glob_lim *); >+static int g_stat(Char *, struct stat *, compat_glob_t *); >+static int glob0(const Char *, compat_glob_t *, struct glob_lim *); >+static int glob1(Char *, Char *, compat_glob_t *, struct glob_lim *); > static int glob2(Char *, Char *, Char *, Char *, Char *, Char *, >- glob_t *, struct glob_lim *); >+ compat_glob_t *, struct glob_lim *); > static int glob3(Char *, Char *, Char *, Char *, Char *, >- Char *, Char *, glob_t *, struct glob_lim *); >-static int globextend(const Char *, glob_t *, struct glob_lim *, >+ Char *, Char *, compat_glob_t *, struct glob_lim *); >+static int globextend(const Char *, compat_glob_t *, struct glob_lim *, > struct stat *); > static const Char * >- globtilde(const Char *, Char *, size_t, glob_t *); >-static int globexp1(const Char *, glob_t *, struct glob_lim *); >-static int globexp2(const Char *, const Char *, glob_t *, >+ globtilde(const Char *, Char *, size_t, compat_glob_t *); >+static int globexp1(const Char *, compat_glob_t *, struct glob_lim *); >+static int globexp2(const Char *, const Char *, compat_glob_t *, > struct glob_lim *); > static int match(Char *, Char *, Char *, int); > #ifdef DEBUG >@@ -174,8 +175,8 @@ static void qprintf(const char *, Char *); > #endif > > int >-glob(const char *pattern, int flags, int (*errfunc)(const char *, int), >- glob_t *pglob) >+__compat_glob(const char *pattern, int flags, int (*errfunc)(const char *, int), >+ compat_glob_t *pglob) > { > const u_char *patnext; > int c; >@@ -233,7 +234,7 @@ glob(const char *pattern, int flags, int (*errfunc)(const char *, int), > * characters > */ > static int >-globexp1(const Char *pattern, glob_t *pglob, struct glob_lim *limitp) >+globexp1(const Char *pattern, compat_glob_t *pglob, struct glob_lim *limitp) > { > const Char* ptr = pattern; > >@@ -254,7 +255,7 @@ globexp1(const Char *pattern, glob_t *pglob, struct glob_lim *limitp) > * If it fails then it tries to glob the rest of the pattern and returns. > */ > static int >-globexp2(const Char *ptr, const Char *pattern, glob_t *pglob, >+globexp2(const Char *ptr, const Char *pattern, compat_glob_t *pglob, > struct glob_lim *limitp) > { > int i, rv; >@@ -359,7 +360,7 @@ globexp2(const Char *ptr, const Char *pattern, glob_t *pglob, > * expand tilde from the passwd file. > */ > static const Char * >-globtilde(const Char *pattern, Char *patbuf, size_t patbuf_len, glob_t *pglob) >+globtilde(const Char *pattern, Char *patbuf, size_t patbuf_len, compat_glob_t *pglob) > { > struct passwd *pwd; > char *h; >@@ -468,7 +469,7 @@ g_charclass(const Char **patternp, Char **bufnextp) > * to find no matches. > */ > static int >-glob0(const Char *pattern, glob_t *pglob, struct glob_lim *limitp) >+glob0(const Char *pattern, compat_glob_t *pglob, struct glob_lim *limitp) > { > const Char *qpatnext; > int c, err, oldpathc; >@@ -606,7 +607,7 @@ compare_gps(const void *_p, const void *_q) > } > > static int >-glob1(Char *pattern, Char *pattern_last, glob_t *pglob, struct glob_lim *limitp) >+glob1(Char *pattern, Char *pattern_last, compat_glob_t *pglob, struct glob_lim *limitp) > { > Char pathbuf[MAXPATHLEN]; > >@@ -625,7 +626,7 @@ glob1(Char *pattern, Char *pattern_last, glob_t *pglob, struct glob_lim *limitp) > */ > static int > glob2(Char *pathbuf, Char *pathbuf_last, Char *pathend, Char *pathend_last, >- Char *pattern, Char *pattern_last, glob_t *pglob, struct glob_lim *limitp) >+ Char *pattern, Char *pattern_last, compat_glob_t *pglob, struct glob_lim *limitp) > { > struct stat sb; > Char *p, *q; >@@ -693,7 +694,7 @@ glob2(Char *pathbuf, Char *pathbuf_last, Char *pathend, Char *pathend_last, > > static int > glob3(Char *pathbuf, Char *pathbuf_last, Char *pathend, Char *pathend_last, >- Char *pattern, Char *restpattern, Char *restpattern_last, glob_t *pglob, >+ Char *pattern, Char *restpattern, Char *restpattern_last, compat_glob_t *pglob, > struct glob_lim *limitp) > { > struct dirent *dp; >@@ -792,7 +793,7 @@ glob3(Char *pathbuf, Char *pathbuf_last, Char *pathend, Char *pathend_last, > * gl_pathv points to (gl_offs + gl_pathc + 1) items. > */ > static int >-globextend(const Char *path, glob_t *pglob, struct glob_lim *limitp, >+globextend(const Char *path, compat_glob_t *pglob, struct glob_lim *limitp, > struct stat *sb) > { > char **pathv; >@@ -956,7 +957,7 @@ match(Char *name, Char *pat, Char *patend, int recur) > > /* Free allocated data belonging to a glob_t structure. */ > void >-globfree(glob_t *pglob) >+__compat_globfree(compat_glob_t *pglob) > { > int i; > char **pp; >@@ -980,7 +981,7 @@ globfree(glob_t *pglob) > } > > static DIR * >-g_opendir(Char *str, glob_t *pglob) >+g_opendir(Char *str, compat_glob_t *pglob) > { > char buf[MAXPATHLEN]; > >@@ -998,7 +999,7 @@ g_opendir(Char *str, glob_t *pglob) > } > > static int >-g_lstat(Char *fn, struct stat *sb, glob_t *pglob) >+g_lstat(Char *fn, struct stat *sb, compat_glob_t *pglob) > { > char buf[MAXPATHLEN]; > >@@ -1010,7 +1011,7 @@ g_lstat(Char *fn, struct stat *sb, glob_t *pglob) > } > > static int >-g_stat(Char *fn, struct stat *sb, glob_t *pglob) >+g_stat(Char *fn, struct stat *sb, compat_glob_t *pglob) > { > char buf[MAXPATHLEN]; > >diff --git a/openbsd-compat/glob.h b/openbsd-compat/glob.h >index f8a7fa5..98518e5 100644 >--- a/openbsd-compat/glob.h >+++ b/openbsd-compat/glob.h >@@ -42,8 +42,8 @@ > !defined(HAVE_DECL_GLOB_NOMATCH) || HAVE_DECL_GLOB_NOMATCH == 0 || \ > defined(BROKEN_GLOB) > >-#ifndef _GLOB_H_ >-#define _GLOB_H_ >+#ifndef _COMPAT_GLOB_H_ >+#define _COMPAT_GLOB_H_ > > #include <sys/stat.h> > >@@ -68,7 +68,7 @@ typedef struct { > void *(*gl_opendir)(const char *); > int (*gl_lstat)(const char *, struct stat *); > int (*gl_stat)(const char *, struct stat *); >-} glob_t; >+} compat_glob_t; > > #define GLOB_APPEND 0x0001 /* Append to output from previous call. */ > #define GLOB_DOOFFS 0x0002 /* Use gl_offs. */ >@@ -93,10 +93,10 @@ typedef struct { > #define GLOB_KEEPSTAT 0x4000 /* Retain stat data for paths in gl_statv. */ > #define GLOB_ABEND GLOB_ABORTED /* backward compatibility */ > >-int glob(const char *, int, int (*)(const char *, int), glob_t *); >-void globfree(glob_t *); >+int __compat_glob(const char *, int, int (*)(const char *, int), compat_glob_t *); >+void __compat_globfree(compat_glob_t *); > >-#endif /* !_GLOB_H_ */ >+#endif /* !_COMPAT_GLOB_H_ */ > > #endif /* !defined(HAVE_GLOB_H) || !defined(GLOB_HAS_ALTDIRFUNC) || > !defined(GLOB_HAS_GL_MATCHC) || !defined(GLOH_HAS_GL_STATV) */ >diff --git a/openbsd-compat/openbsd-compat.h b/openbsd-compat/openbsd-compat.h >index 1ff7114..8cc8a11 100644 >--- a/openbsd-compat/openbsd-compat.h >+++ b/openbsd-compat/openbsd-compat.h >@@ -39,7 +39,6 @@ > /* OpenBSD function replacements */ > #include "base64.h" > #include "sigact.h" >-#include "glob.h" > #include "readpassphrase.h" > #include "vis.h" > #include "getrrsetbyname.h" >diff --git a/sftp-client.h b/sftp-client.h >index f814b07..c88ed31 100644 >--- a/sftp-client.h >+++ b/sftp-client.h >@@ -21,6 +21,18 @@ > #ifndef _SFTP_CLIENT_H > #define _SFTP_CLIENT_H > >+#if defined(HAVE_GLOB_H) && defined(GLOB_HAS_ALTDIRFUNC) && \ >+ defined(GLOB_HAS_GL_MATCHC) && defined(GLOB_HAS_GL_STATV) && \ >+ defined(HAVE_DECL_GLOB_NOMATCH) && HAVE_DECL_GLOB_NOMATCH != 0 && \ >+ !defined(BROKEN_GLOB) >+# include <glob.h> >+#else >+# include "openbsd-compat/glob.h" >+# define glob_t compat_glob_t >+# define glob(a, b, c, d) __compat_glob((a), (b), (c), (d)) >+# define globfree(a) __compat_globfree((a)) >+#endif >+ > typedef struct SFTP_DIRENT SFTP_DIRENT; > > struct SFTP_DIRENT { >-- >2.1.0 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 2463
:
2701
|
2704
|
2707
|
2708
|
2709