[gcr/nielsdg/cn-can-be-null] gcr: Fix criticals if a CN is null




commit 85d0e8d5c3d929cabfedada26fe3ba053eae2724
Author: Niels De Graef <nielsdegraef gmail com>
Date:   Tue Aug 9 23:02:01 2022 +0200

    gcr: Fix criticals if a CN is null
    
    Both the issuer CN and the subject CN can be NULL, so make sure we deal
    with this case. This fixes a few CRITICALs when loading a certificate
    that has this.

 gcr/gcr-certificate.c | 4 ++++
 1 file changed, 4 insertions(+)
---
diff --git a/gcr/gcr-certificate.c b/gcr/gcr-certificate.c
index a11cf1e8..2a38efbf 100644
--- a/gcr/gcr-certificate.c
+++ b/gcr/gcr-certificate.c
@@ -1179,9 +1179,13 @@ gcr_certificate_get_interface_elements (GcrCertificate *self)
        g_clear_pointer (&display, g_free);
 
        display = gcr_certificate_get_subject_cn (self);
+       if (display == NULL)
+               display = g_strdup (_("Unknown"));
        _gcr_certificate_section_new_field_take_value (section, _("Identity"), g_steal_pointer (&display));
 
        display = gcr_certificate_get_issuer_cn (self);
+       if (display == NULL)
+               display = g_strdup (_("Unknown"));
        _gcr_certificate_section_new_field_take_value (section, _("Verified by"), g_steal_pointer (&display));
 
        datetime = gcr_certificate_get_expiry_date (self);


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