]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
Prevent name collisions with system glob (bz#2463)
authorDarren Tucker <dtucker@zip.com.au>
Wed, 28 Oct 2015 23:48:23 +0000 (10:48 +1100)
committerDarren Tucker <dtucker@zip.com.au>
Wed, 28 Oct 2015 23:48:23 +0000 (10:48 +1100)
Move glob.h from includes.h to the only caller (sftp) and override the
names for the symbols.  This prevents name collisions with the system glob
in the case where something other than ssh uses it (eg kerberos).  With
jjelen at redhat.com, ok djm@

defines.h
includes.h
openbsd-compat/glob.c
openbsd-compat/glob.h
openbsd-compat/openbsd-compat.h
sftp-client.h

index fa0ccba7c018f60eeac1a4c78e08a3247c24fcd1..a438ddd742f7759f70846df1be351a93f943cd50 100644 (file)
--- a/defines.h
+++ b/defines.h
@@ -850,4 +850,11 @@ struct winsize {
 # endif /* gcc version */
 #endif /* __predict_true */
 
+#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)
+# define USE_SYSTEM_GLOB
+#endif
+
 #endif /* _DEFINES_H */
index 2893a54cdc6bfbcaa41998ee5bb01abf12d28de5..497a038b23732d807fcdec6160b8476a00bb13a6 100644 (file)
 #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
index 742b4b954a32f66a6afff4b1727f7bdcd141096e..7c97e67f557cc827e19bdc3b20bee7d284f4586e 100644 (file)
@@ -59,6 +59,7 @@
  */
 
 #include "includes.h"
+#include "glob.h"
 
 #include <sys/types.h>
 #include <sys/stat.h>
index f8a7fa5ffe3e11214f311ebbe2d5744ce8662080..f069a05dc6561379d51e87055131844b3c309f67 100644 (file)
     !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>
 
+# define glob_t _ssh_compat_glob_t
+# define glob(a, b, c, d)  _ssh__compat_glob(a, b, c, d)
+# define globfree(a)  _ssh__compat_globfree(a)
+
 struct stat;
 typedef struct {
        int gl_pathc;           /* Count of total paths so far. */
index 1ff7114ef3daedeb000ce40ae8e001355bd12850..8cc8a11b7617c379380b2fe087163999f9cc9472 100644 (file)
@@ -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"
index f814b07d6c8862c3ae890dbe698123fb9cf6fa4d..14a3b8182c490bb7799f56e22d0fc96f168dcb71 100644 (file)
 #ifndef _SFTP_CLIENT_H
 #define _SFTP_CLIENT_H
 
+#ifdef USE_SYSTEM_GLOB
+# include <glob.h>
+#else
+# include "openbsd-compat/glob.h"
+#endif
+
 typedef struct SFTP_DIRENT SFTP_DIRENT;
 
 struct SFTP_DIRENT {