On Mon, Feb 18, 2008 at 02:41:09PM +0100, Jim Meyering wrote:
"Daniel P. Berrange" <berrange(a)redhat.com> 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.
Ok. Will do.
> + *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?
Yes, it should do.
Dan.
--
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=|
|=- Perl modules:
http://search.cpan.org/~danberr/ -=|
|=- Projects:
http://freshmeat.net/~danielpb/ -=|
|=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|