On Sun, Jun 18, 2017 at 10:28:13AM +0200, Tobias Schramm wrote:
@@ -1469,6 +1472,28 @@ static int local_parse_opts(QemuOpts *opts, struct FsDriverEntry *fse)fse->path = g_strdup(path); + fse->fmask = SM_LOCAL_MODE_BITS; + if (fmask) { + mask = strtol(fmask, NULL, 0);
(Use qemu_strtol(), or maybe parse_uint() since it has to be positive)If a mode without the '0' prefix is supplied (as required by strtol to parse an octal), the input will be parsed as a decimal and will result in a wrong value. Also, maybe you should check for mask > 0777 and for negative input as well instead of &ing.
+ if((!mask || mask == LONG_MIN || mask == LONG_MAX) && errno) + { + error_report("Invalid fmask %s specified", fmask); + return -1; + } + fse->fmask = ((mode_t)mask) & 0777; + } + + fse->dmask = SM_LOCAL_DIR_MODE_BITS; + if (dmask) { + mask = strtol(dmask, NULL, 0); + if((!mask || mask == LONG_MIN || mask == LONG_MAX) && errno) + { + error_report("Invalid dmask %s specified", dmask); + return -1; + } + fse->dmask = ((mode_t)mask) & 0777;
Same here.
+ } + return 0; } diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 96d2683348..40290dbade 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -3533,6 +3533,9 @@ int v9fs_device_realize_common(V9fsState *s, Error **errp) s->ops = fse->ops; + s->ctx.fmask = fse->fmask; + s->ctx.dmask = fse->dmask; + s->fid_list = NULL; qemu_co_rwlock_init(&s->rename_lock); -- 2.13.1
signature.asc
Description: PGP signature