[libvirt] [PATCH] Coverity fix for virNetDevIPCheckIPv6ForwardingCallback
Peter Krempa
pkrempa at redhat.com
Fri Mar 24 12:10:54 UTC 2017
On Fri, Mar 24, 2017 at 13:04:07 +0100, Cédric Bosdonnat wrote:
> Add check for more than one RTA_OIF, even though this is rather
> unlikely and get rid of the buggy switch / break.
> ---
> src/util/virnetdevip.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
Making coverity happy is a weak justification.
> diff --git a/src/util/virnetdevip.c b/src/util/virnetdevip.c
> index c9ac6baf7..f5662413a 100644
> --- a/src/util/virnetdevip.c
> +++ b/src/util/virnetdevip.c
> @@ -556,15 +556,17 @@ virNetDevIPCheckIPv6ForwardingCallback(const struct nlmsghdr *resp,
> if (resp->nlmsg_type != RTM_NEWROUTE)
> return ret;
>
> - /* Extract a few attributes */
> + /* Extract a device ID attribute */
> for (rta = RTM_RTA(rtmsg); RTA_OK(rta, len); rta = RTA_NEXT(rta, len)) {
> - switch (rta->rta_type) {
> - case RTA_OIF:
> + if (rta->rta_type == RTA_OIF) {
This removes future expandability.
> oif = *(int *)RTA_DATA(rta);
>
> + /* Should never happen: netlink message would be broken */
> + if (ifname)
> + goto error;
This is weird. I know it's in a loop, but this jumps out without
reporting an error, which would make debugging even harder than in case
of a leak.
> +
> if (!(ifname = virNetDevGetName(oif)))
> goto error;
> - break;
> }
> }
>
> --
> 2.12.0
>
> --
> libvir-list mailing list
> libvir-list at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20170324/6bcd03ad/attachment-0001.sig>
More information about the libvir-list
mailing list