[libgovirt] Fix memory corruption when RestProxy::ssl-ca-file does not exist



commit 7ef6a0e08d94215e2a995535a453aec889dbbda1
Author: Christophe Fergeau <cfergeau redhat com>
Date:   Tue Nov 26 18:17:10 2013 +0100

    Fix memory corruption when RestProxy::ssl-ca-file does not exist
    
    Older librest releases don't have the RestProxy::ssl-ca-file property.
    Without this property, we are not going to be able to set the CA
    certificate to use to validate the oVirt instance TLS certificate, but we
    should at least be able to report a connection error.
    However, g_object_get() will not set its parameter to NULL when the
    property does not exist, so we need to set it to NULL ourselves before
    calling g_object_get() if we want to rely on that.
    
    If we don't do that, 'ca_file' will be uninitialized when
    RestProxy::ssl-ca-file does not exist, and get_ca_cert_data() will call
    g_free() on that variable, causing memory corruption.

 govirt/ovirt-proxy.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/govirt/ovirt-proxy.c b/govirt/ovirt-proxy.c
index 43124d6..b4ee32f 100644
--- a/govirt/ovirt-proxy.c
+++ b/govirt/ovirt-proxy.c
@@ -405,7 +405,7 @@ error:
 
 static GByteArray *get_ca_cert_data(OvirtProxy *proxy)
 {
-    char *ca_file;
+    char *ca_file = NULL;
     char *content;
     gsize length;
     GError *error = NULL;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]