[Libguestfs] [PATCH libnbd 7/9] generator: On entry to API functions, check Flags and OFlags parameters.

Eric Blake eblake at redhat.com
Mon Aug 12 13:19:25 UTC 2019


On 8/11/19 3:30 AM, Richard W.M. Jones wrote:
> On Sun, Aug 11, 2019 at 09:26:14AM +0100, Richard W.M. Jones wrote:
>> On Sat, Aug 10, 2019 at 04:38:20PM -0500, Eric Blake wrote:
>>> Some of the checks in lib/rw.c are now unreachable with this in place.
>>> Is it worth simplifying that?  (But not all of them - there are still
>>> checks that depend on runtime values, such as nbd_pread accepting _DF
>>> only if the server advertises it after the client requests structured
>>> replies).  Also, this lets us pass all four existing command flags to
>>> all commands that accept an OFlags parameter, even though none of the
>>> commands accept all flags at once - the real protection being added here
>>> is the check for completely unrecognized flags.
>>
>> Right - this doesn't replace fine-grained checks in the functions
>> themselves.  I'll have a look at lib/rw.c and see what checks might be
>> removed.
> 
> Hmm - I think all the flag tests in lib/rw.c are still necessary ..?

Yeah, it looks like that is the case for the current code. We have the
common pattern of checking that only flags valid for the particular
command are present, followed by runtime checks that each flag requested
can actually be sent.  The first check could be moved into the
generator, but only if we let the generator track the subset of flags
valid for a given command; but it's just as easy to keep that first
check in rw.c and have the generator do the simpler check for no flags
that are completely unknown.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org

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


More information about the Libguestfs mailing list