On 02/01/2018 08:53 AM, Richard W.M. Jones wrote:
On Wed, Jan 31, 2018 at 09:26:39PM -0600, Eric Blake wrote:
> +static int
> +blocksize_parse (const char *name, const char *s, unsigned int *v)
Maybe use nbdkit_parse_size?
Oh, duh. I should have looked for that, instead of rolling my own.
I will, however, point out that nbdkit_parse_size() is currently rather
lame in the face of integer overflow. For starters, sscanf() has
undefined behavior when you pass more digits than fit in a %d or
comparable conversion specifier (some applications of scanf are safe,
especially if you trust the input; but this is an unsafe use); then the
code further performs scaling without checking for overflow. If we want
to be more robust at detecting garbage input, manual use of strtol() is
more robust, so I may do a separate patch to merge my independent
implementation into the common code.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization:
qemu.org |
libvirt.org