diff options
author | des <des@FreeBSD.org> | 2002-06-27 22:31:32 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 2002-06-27 22:31:32 +0000 |
commit | 0a087122156c6e3b13e8ed52302709f7bbd480d6 (patch) | |
tree | 58be71224312e3d86a840a2b75349aeb61e28618 /crypto/openssh/sftp-glob.c | |
parent | 325c48d385c1cbdfe85f44e050eaf399960376ae (diff) | |
parent | bb02848f18878bddada7a9f55b110116f63c2f3c (diff) | |
download | FreeBSD-src-0a087122156c6e3b13e8ed52302709f7bbd480d6.zip FreeBSD-src-0a087122156c6e3b13e8ed52302709f7bbd480d6.tar.gz |
This commit was generated by cvs2svn to compensate for changes in r98937,
which included commits to RCS files with non-trunk default branches.
Diffstat (limited to 'crypto/openssh/sftp-glob.c')
-rw-r--r-- | crypto/openssh/sftp-glob.c | 40 |
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 |