Re: [Libguestfs] [PATCH libnbd 5/9] generator: On entry to API functions, check Enum parameters.

Eric Blake
2019-08-10T17:42:15Z

On 8/10/19 8:02 AM, Richard W.M. Jones wrote:
> In the generated wrapper code this adds checks for all Enum
> parameters.  Since only nbd_set_tls uses an Enum parameter, the only
> extra code generated by this change is:
>
>   int
>   nbd_set_tls (struct nbd_handle *h, int tls) {
>     // ...
>     switch (tls) {
>     case LIBNBD_TLS_DISABLE:
>     case LIBNBD_TLS_ALLOW:
>     case LIBNBD_TLS_REQUIRE:
>       break;
>     default:
>       set_error (EINVAL, "%s: invalid value for parameter: %d",
>                  "tls", tls);
>       ret = -1;
>       goto out;
>     }
>
> This doesn't change the C API, but previously this parameter was not
> checked.  So programs using this API which previously happened to work
> would now get an error.

programs using this API with an out-of-bounds value

(it doesn't change programs using it as documented)

> ---
>  generator/generator | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
>

ACK.

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