samba3.5.1pre01 - create time - change in sys_stat, sys_fstat and sys_lstat

Volker Lendecke Volker.Lendecke at SerNet.DE
Sat Dec 5 06:39:14 MST 2009


On Thu, Dec 03, 2009 at 02:26:09PM +0200, Dina Fine wrote:
> It seems that system call wrappers sys_stat, sys_fstat and sys_lstat
> have a bug when calling stat and not stat64.

Hmmm. Looking at the code I'm not sure I can follow you.
The way I see it is that the stat64 support is broken: We
never define the variable statbuf in that case.

> temp stat struct " struct stat statbuf" is used to get the file stat
> information inside the ifdef block. But you use this temp stat also
> outside the block even if it was not initiated at all, causing the stat
> replies be a garbage.

Where do you see the code path that "statbuf" is not
initialized at all? If I remove the #if stat64 case, I end
up with

int sys_stat(const char *fname, SMB_STRUCT_STAT *sbuf,
             bool fake_dir_create_times)
{
        int ret;
        struct stat statbuf;
        ret = stat(fname, &statbuf);
        if (ret == 0) {
                /* we always want directories to appear zero size */
                if (S_ISDIR(statbuf.st_mode)) {
                        statbuf.st_size = 0;
                }
                init_stat_ex_from_stat(sbuf, &statbuf, fake_dir_create_times);
        }
        return ret;
}

To me this looks completely okay, we initialize statbuf in
the stat call and make use of it only when the stat call
indicated success. But probably I'm just missing something
very simple :-)

The attached patch is supposed to fix the (probably these
days completely unused) stat64 case.

Volker
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-s3-Fix-explicit-stat64-support.patch
Type: text/x-diff
Size: 2020 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20091205/21eee2bf/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20091205/21eee2bf/attachment.pgp>


More information about the samba-technical mailing list