summaryrefslogtreecommitdiffstats
path: root/crypto/openssh/sftp-glob.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/openssh/sftp-glob.c')
-rw-r--r--crypto/openssh/sftp-glob.c40
1 files changed, 31 insertions, 9 deletions
diff --git a/crypto/openssh/sftp-glob.c b/crypto/openssh/sftp-glob.c
index 1d845d3..1234074 100644
--- a/crypto/openssh/sftp-glob.c
+++ b/crypto/openssh/sftp-glob.c
@@ -25,8 +25,6 @@
#include "includes.h"
RCSID("$OpenBSD: sftp-glob.c,v 1.10 2002/02/13 00:59:23 djm Exp $");
-#include <glob.h>
-
#include "buffer.h"
#include "bufaux.h"
#include "xmalloc.h"
@@ -64,16 +62,40 @@ fudge_opendir(const char *path)
static struct dirent *
fudge_readdir(struct SFTP_OPENDIR *od)
{
- static struct dirent ret;
-
+ /* Solaris needs sizeof(dirent) + path length (see below) */
+ static char buf[sizeof(struct dirent) + MAXPATHLEN];
+ struct dirent *ret = (struct dirent *)buf;
+#ifdef __GNU_LIBRARY__
+ static int inum = 1;
+#endif /* __GNU_LIBRARY__ */
+
if (od->dir[od->offset] == NULL)
return(NULL);
- memset(&ret, 0, sizeof(ret));
- strlcpy(ret.d_name, od->dir[od->offset++]->filename,
- sizeof(ret.d_name));
-
- return(&ret);
+ memset(buf, 0, sizeof(buf));
+
+ /*
+ * Solaris defines dirent->d_name as a one byte array and expects
+ * you to hack around it.
+ */
+#ifdef BROKEN_ONE_BYTE_DIRENT_D_NAME
+ strlcpy(ret->d_name, od->dir[od->offset++]->filename, MAXPATHLEN);
+#else
+ strlcpy(ret->d_name, od->dir[od->offset++]->filename,
+ sizeof(ret->d_name));
+#endif
+#ifdef __GNU_LIBRARY__
+ /*
+ * Idiot glibc uses extensions to struct dirent for readdir with
+ * ALTDIRFUNCs. Not that this is documented anywhere but the
+ * source... Fake an inode number to appease it.
+ */
+ ret->d_ino = inum++;
+ if (!inum)
+ inum = 1;
+#endif /* __GNU_LIBRARY__ */
+
+ return(ret);
}
static void
OpenPOWER on IntegriCloud