[Libguestfs] [PATCH] fuse: clear stat structs (RHBZ#660687).

Richard W.M. Jones rjones at redhat.com
Thu Jan 16 15:25:23 UTC 2014


On Wed, Jan 15, 2014 at 07:02:03PM +0100, Pino Toscano wrote:
> Not all the fields of struct stat are actually filled by us. This caused
> rubbish to appear in the microseconds fields, which were then used as
> base when changing atime/ctime (with e.g. touch), triggering EINVAL by
> futimens/utimensat when those rubbish values were out of the range
> allowed for microseconds.
> ---
>  src/fuse.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/src/fuse.c b/src/fuse.c
> index 288c02a..dd4f139 100644
> --- a/src/fuse.c
> +++ b/src/fuse.c
> @@ -175,6 +175,7 @@ mount_local_readdir (const char *path, void *buf, fuse_fill_dir_t filler,
>          if (ss->val[i].ino >= 0) {
>            struct stat statbuf;
>  
> +          memset (&statbuf, 0, sizeof statbuf);
>            statbuf.st_dev = ss->val[i].dev;
>            statbuf.st_ino = ss->val[i].ino;
>            statbuf.st_mode = ss->val[i].mode;
> @@ -255,6 +256,7 @@ mount_local_getattr (const char *path, struct stat *statbuf)
>    if (r == NULL)
>      RETURN_ERRNO;
>  
> +  memset (statbuf, 0, sizeof *statbuf);
>    statbuf->st_dev = r->dev;
>    statbuf->st_ino = r->ino;
>    statbuf->st_mode = r->mode;
> -- 

Ah ha ...  mystery solved.

ACK.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW




More information about the Libguestfs mailing list