summaryrefslogtreecommitdiff
path: root/source4/lib/replace
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2006-10-01 20:45:46 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:20:28 -0500
commit127c96f49905291b4566c2a1bc25d882ae111466 (patch)
tree642212a8512472c2fcca9127bc1ae0639723442d /source4/lib/replace
parentbf86ece6cb9ff38bd08fb39988d9dc7577ea3f99 (diff)
downloadsamba-127c96f49905291b4566c2a1bc25d882ae111466.tar.gz
samba-127c96f49905291b4566c2a1bc25d882ae111466.tar.bz2
samba-127c96f49905291b4566c2a1bc25d882ae111466.zip
r19017: Merge from Samba3:
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? This includes the tabs->spaces fix requested by Stefan. Volker (This used to be commit 7b9ee1171ddc89537ba3b286f20c722fb70c980b)
Diffstat (limited to 'source4/lib/replace')
-rw-r--r--source4/lib/replace/repdir_getdents.c12
-rw-r--r--source4/lib/replace/repdir_getdirentries.c12
2 files changed, 24 insertions, 0 deletions
diff --git a/source4/lib/replace/repdir_getdents.c b/source4/lib/replace/repdir_getdents.c
index 07b9568dc1..6b115c4c4f 100644
--- a/source4/lib/replace/repdir_getdents.c
+++ b/source4/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/source4/lib/replace/repdir_getdirentries.c b/source4/lib/replace/repdir_getdirentries.c
index 9e4b63145c..a6026dfb5d 100644
--- a/source4/lib/replace/repdir_getdirentries.c
+++ b/source4/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;