diff options
author | Volker Lendecke <vlendec@samba.org> | 2006-09-30 14:12:02 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:14:57 -0500 |
commit | bffbda804d706808b2298ab535e8436d25a8b563 (patch) | |
tree | b81c32d59f69c3fa5fe4edb37614546bfb33a73b /source3/lib | |
parent | 9430017b304b5d88cb12bcb67b531c66b6a6fdcd (diff) | |
download | samba-bffbda804d706808b2298ab535e8436d25a8b563.tar.gz samba-bffbda804d706808b2298ab535e8436d25a8b563.tar.bz2 samba-bffbda804d706808b2298ab535e8436d25a8b563.zip |
r19011: Attempt to fix the BSD RAW-CHKPATH failures: In Samba3 we rely on opendir
returning ENOTDIR when the file opened is not a directory. Can we merge this
back into Samba4?
Volker
(This used to be commit 448d7c0c4b6a1d7d9c544d39d7b461dd1c69fd8e)
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/replace/repdir_getdents.c | 12 | ||||
-rw-r--r-- | source3/lib/replace/repdir_getdirentries.c | 12 |
2 files changed, 24 insertions, 0 deletions
diff --git a/source3/lib/replace/repdir_getdents.c b/source3/lib/replace/repdir_getdents.c index 07b9568dc1..3bf76ee858 100644 --- a/source3/lib/replace/repdir_getdents.c +++ b/source3/lib/replace/repdir_getdents.c @@ -68,6 +68,7 @@ struct dir_buf { DIR *opendir(const char *dname) { struct dir_buf *d; + struct stat sb; d = malloc(sizeof(*d)); if (d == NULL) { errno = ENOMEM; @@ -78,6 +79,17 @@ DIR *opendir(const char *dname) free(d); return NULL; } + if (fstat(d->fd, &sb) < 0) { + close(d->fd); + free(d); + return NULL; + } + if (!S_ISDIR(sb.st_mode)) { + close(d->fd); + free(d); + errno = ENOTDIR; + return NULL; + } d->ofs = 0; d->seekpos = 0; d->nbytes = 0; diff --git a/source3/lib/replace/repdir_getdirentries.c b/source3/lib/replace/repdir_getdirentries.c index 9e4b63145c..ee1d218456 100644 --- a/source3/lib/replace/repdir_getdirentries.c +++ b/source3/lib/replace/repdir_getdirentries.c @@ -70,6 +70,7 @@ struct dir_buf { DIR *opendir(const char *dname) { struct dir_buf *d; + struct stat sb; d = malloc(sizeof(*d)); if (d == NULL) { errno = ENOMEM; @@ -80,6 +81,17 @@ DIR *opendir(const char *dname) free(d); return NULL; } + if (fstat(d->fd, &sb) < 0) { + close(d->fd); + free(d); + return NULL; + } + if (!S_ISDIR(sb.st_mode)) { + close(d->fd); + free(d); + errno = ENOTDIR; + return NULL; + } d->ofs = 0; d->seekpos = 0; d->nbytes = 0; |