s3:smbd: initialize stat_ex buffer in smbd_dirptr_get_entry()
authorMichael Adam <obnox@samba.org>
Thu, 3 Jul 2014 08:00:13 +0000 (10:00 +0200)
committerChristof Schmitt <cs@samba.org>
Sun, 13 Jul 2014 09:26:57 +0000 (11:26 +0200)
This prevents random garbage in the vfs_private member.
Usually it should not be a problem to leave initialization
of the vfs_private to the vfs module who wants to use it,
but further down in the directory listing code, in
vfswrap_readdir, there is in optimization introduced
with 2a65e8befef004fd18d17853a1b72155752346c8, to call
fstatat if possible to already fill stat info in the
readdir call.

The problem is that this calls fstatat directly,
not going through VFS, but still making the stat buffer
valid, leaving vfs_private with random garbage.
Hence a vfs module using vfs_private, like vfs_gpfs
does for offline info (and winAttrs in general)
does not have a chance to tell whether the vfs_private
is valid if the stat buffer is marked valid.
This is a reason for the "flapping offline flag" problem
of the vfs_gpfs module.

Initializing the vfs_private to 0 here will for the
vfs_gpfs module result in files being marked online
always in a directory listing. So this is not a real fix
but it does at least make the problem less random.

A real general fix might be to implement SMB_VFS_FSTATAT()
and use it here.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Christof Schmitt <cs@samba.org>
Autobuild-User(master): Christof Schmitt <cs@samba.org>
Autobuild-Date(master): Sun Jul 13 11:26:58 CEST 2014 on sn-devel-104

source3/smbd/dir.c

index 038281e599ca5338bcf18a7ca2ff152ca9411999..818f77895e406c61b9cece44a4e1eed5d977b40c 100644 (file)
@@ -1126,7 +1126,7 @@ bool smbd_dirptr_get_entry(TALLOC_CTX *ctx,
        while (true) {
                long cur_offset;
                long prev_offset;
-               SMB_STRUCT_STAT sbuf;
+               SMB_STRUCT_STAT sbuf = { 0 };
                char *dname = NULL;
                bool isdots;
                char *fname = NULL;