[libvirt] [PATCH v2 1/2] lxc: Initializing IPv6 and IPv4 gateway to overwrite old settings.

Julio Faracco posted 2 patches 7 years, 2 months ago
There is a newer version of this series
[libvirt] [PATCH v2 1/2] lxc: Initializing IPv6 and IPv4 gateway to overwrite old settings.
Posted by Julio Faracco 7 years, 2 months ago
This commit fixes a bug when you have multiple network settings defined.
Basically, if you set an IPv6 or IPv4 gateway, it carries on next
network settings. It is happening because the data is not being
initialized when a new network type is defined. So, the old data still
persists into the pointer.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
---
 src/lxc/lxc_native.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c
index 9f6d4b3de8..246623d4a1 100644
--- a/src/lxc/lxc_native.c
+++ b/src/lxc/lxc_native.c
@@ -583,6 +583,9 @@ lxcNetworkWalkCallback(const char *name, virConfValuePtr value, void *data)
         parseData->ips = NULL;
         parseData->nips = 0;
 
+        parseData->gateway_ipv4 = NULL;
+        parseData->gateway_ipv6 = NULL;
+
         /* Keep the new value */
         parseData->type = value->str;
     }
-- 
2.19.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 1/2] lxc: Initializing IPv6 and IPv4 gateway to overwrite old settings.
Posted by Michal Privoznik 7 years, 2 months ago
On 11/28/18 4:38 AM, Julio Faracco wrote:
> This commit fixes a bug when you have multiple network settings defined.
> Basically, if you set an IPv6 or IPv4 gateway, it carries on next
> network settings. It is happening because the data is not being
> initialized when a new network type is defined. So, the old data still
> persists into the pointer.
> 
> Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
> ---
>  src/lxc/lxc_native.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c
> index 9f6d4b3de8..246623d4a1 100644
> --- a/src/lxc/lxc_native.c
> +++ b/src/lxc/lxc_native.c
> @@ -583,6 +583,9 @@ lxcNetworkWalkCallback(const char *name, virConfValuePtr value, void *data)
>          parseData->ips = NULL;
>          parseData->nips = 0;
>  
> +        parseData->gateway_ipv4 = NULL;
> +        parseData->gateway_ipv6 = NULL;
> +
>          /* Keep the new value */
>          parseData->type = value->str;
>      }
> 

So all members are reset except .def, .networks, .privnet. How about
storing them in a temporary variables and calling memset? Alternatively,
we can have a temp variable with c99 initialization + memcpy.

This is just horrible. It's very easy to clear out new member (should
they be added).

Michal

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list