qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 06/28] 9pfs: local: open/opendir: don't follo


From: Greg Kurz
Subject: Re: [Qemu-devel] [PATCH v2 06/28] 9pfs: local: open/opendir: don't follow symlinks
Date: Mon, 27 Feb 2017 15:35:19 +0100

On Mon, 27 Feb 2017 12:49:01 +0000
Stefan Hajnoczi <address@hidden> wrote:

> On Sun, Feb 26, 2017 at 11:42:18PM +0100, Greg Kurz wrote:
> > @@ -48,6 +49,24 @@ typedef struct {
> >      int mountfd;
> >  } LocalData;
> >  
> > +int local_open_nofollow(FsContext *fs_ctx, const char *path, int flags,
> > +                        mode_t mode)
> > +{
> > +    LocalData *data = fs_ctx->private;
> > +
> > +    /* All paths are relative to the path data->mountfd points to */
> > +    while (*path == '/') {
> > +        path++;
> > +    }
> > +
> > +    return openat_nofollow(data->mountfd, path, flags, mode);  
> 
> What about all the other openat_nofollow() users?  They don't explicitly

$ git grep openat_nofollow
hw/9pfs/9p-local.c:    return openat_nofollow(data->mountfd, path, flags, mode);
hw/9pfs/9p-util.c:int openat_nofollow(int dirfd, const char *path, int flags, 
mode_t mode)
hw/9pfs/9p-util.h:int openat_nofollow(int dirfd, const char *path, int flags, 
mode_t mode);

> strip leading slashes.  Perhaps this should be part of a renamed
> relative_openat_nofollow() function.
> 
> > +}
> > +
> > +int local_opendir_nofollow(FsContext *fs_ctx, const char *path)
> > +{
> > +    return local_open_nofollow(fs_ctx, path, O_DIRECTORY | O_RDONLY, 0);  
> 
> Why not strip slashes here?

Because this one calls the other one above.

Attachment: pgpzy32_X4eKx.pgp
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]