[glib-networking] openssl: Fix buffer overflows introduced in 588d8fb2



commit ace5265b16c91903c6d1d86d94eb1ca6a6ee125d
Author: Michael Catanzaro <mcatanzaro redhat com>
Date:   Wed Jun 23 14:07:17 2021 -0500

    openssl: Fix buffer overflows introduced in 588d8fb2
    
    Oops, we need to ensure the BIO contains a NUL terminator before
    converting it to a string.

 tls/openssl/gtlscertificate-openssl.c | 2 ++
 1 file changed, 2 insertions(+)
---
diff --git a/tls/openssl/gtlscertificate-openssl.c b/tls/openssl/gtlscertificate-openssl.c
index dd9664c..cbb8f82 100644
--- a/tls/openssl/gtlscertificate-openssl.c
+++ b/tls/openssl/gtlscertificate-openssl.c
@@ -167,6 +167,7 @@ g_tls_certificate_openssl_get_property (GObject    *object,
       bio = BIO_new (BIO_s_mem ());
       name = X509_get_subject_name (openssl->cert);
       X509_NAME_print_ex (bio, name, 0, XN_FLAG_SEP_COMMA_PLUS);
+      BIO_write (bio, "\0", 1);
       BIO_get_mem_data (bio, (char **)&name_string);
       g_value_set_string (value, name_string);
       BIO_free_all (bio);
@@ -176,6 +177,7 @@ g_tls_certificate_openssl_get_property (GObject    *object,
       bio = BIO_new (BIO_s_mem ());
       name = X509_get_issuer_name (openssl->cert);
       X509_NAME_print_ex (bio, name, 0, XN_FLAG_SEP_COMMA_PLUS);
+      BIO_write (bio, "\0", 1);
       BIO_get_mem_data (bio, &name_string);
       g_value_set_string (value, name_string);
       BIO_free_all (bio);


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