[Libguestfs] [nbdkit PATCH v2 3/3] filters: Add blocksize filter

Eric Blake eblake at redhat.com
Thu Feb 1 15:20:44 UTC 2018


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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20180201/400a569d/attachment.sig>


More information about the Libguestfs mailing list