On Mon, 27 Feb 2017 12:49:01 +0000 Stefan Hajnoczi <[email protected]> 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.
pgp75xpMhyz5g.pgp
Description: OpenPGP digital signature
