"Daniel P. Berrange" <berrange@xxxxxxxxxx> wrote: ... > diff -r 77cf7f42edd4 src/storage_conf.c > --- /dev/null Thu Jan 01 00:00:00 1970 +0000 > +++ b/src/storage_conf.c Thu Feb 07 12:59:40 2008 -0500 ... > +static int virStoragePoolDefParsePerms(virConnectPtr conn, xmlXPathContextPtr ctxt, virStoragePermsPtr perms) { > + char *mode; > + long v; > + > + mode = virXPathString("string(/pool/permissions/mode)", ctxt); > + if (!mode) { > + perms->mode = 0700; > + } else { > + char *end; > + perms->mode = strtol(mode, &end, 8); > + if (end && *end) { > + virStorageReportError(conn, VIR_ERR_XML_ERROR, "malformed octal mode"); > + return -1; > + } > + } ... As long as you're checking for invalid inputs, you might as well check for a couple other cases: negative: -01, and overflow: (otherwise, 07777777777777777777777777777 is accepted) And you can drop the "end &&" part, since "end" will never be NULL. if (*end || perms->mode < 0 || perms->mode > 0777) { > + if (!mode) { > + perms->mode = 0600; > + } else { > + char *end; > + perms->mode = strtol(mode, &end, 8); > + if (end && *end) { Same here. ... > + *ret = strtoull(val, &end, 10); > + if (end && *end) { > + virStorageReportError(conn, VIR_ERR_XML_ERROR, "malformed capacity element"); > + return -1; Maybe use virStrToLong_ui instead of strtoull here? -- Libvir-list mailing list Libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list