about summary refs log tree commit diff stats
path: root/src/config/tlscerts.c
diff options
context:
space:
mode:
authorJohn Hernandez <129467592+H3rnand3zzz@users.noreply.github.com>2023-04-19 02:44:19 +0200
committerJohn Hernandez <129467592+H3rnand3zzz@users.noreply.github.com>2023-05-04 16:15:09 +0200
commit7f3fca2bd081a729d425184f7a0484025862257e (patch)
tree20f1cd78bf48f7d6ceb95bb0262faf691001bcf9 /src/config/tlscerts.c
parentfaccf24c759d7bddb4d3062c7f044e0c7640ffe7 (diff)
downloadprofani-tty-7f3fca2bd081a729d425184f7a0484025862257e.tar.gz
Cleanup: gchar as gchar instead of char
Use gchar instead of char in most of the cases where gchar is intended.

Reason: improve compatibility and stability. Issue #1819

Minor refactoring.
Diffstat (limited to 'src/config/tlscerts.c')
-rw-r--r--src/config/tlscerts.c46
1 files changed, 14 insertions, 32 deletions
diff --git a/src/config/tlscerts.c b/src/config/tlscerts.c
index 008d28f6..d2f053fa 100644
--- a/src/config/tlscerts.c
+++ b/src/config/tlscerts.c
@@ -121,26 +121,17 @@ tlscerts_list(void)
     for (int i = 0; i < g_strv_length(groups); i++) {
         char* fingerprint = strdup(groups[i]);
         int version = g_key_file_get_integer(tlscerts, fingerprint, "version", NULL);
-        char* serialnumber = g_key_file_get_string(tlscerts, fingerprint, "serialnumber", NULL);
-        char* subjectname = g_key_file_get_string(tlscerts, fingerprint, "subjectname", NULL);
-        char* issuername = g_key_file_get_string(tlscerts, fingerprint, "issuername", NULL);
-        char* notbefore = g_key_file_get_string(tlscerts, fingerprint, "start", NULL);
-        char* notafter = g_key_file_get_string(tlscerts, fingerprint, "end", NULL);
-        char* keyalg = g_key_file_get_string(tlscerts, fingerprint, "keyalg", NULL);
-        char* signaturealg = g_key_file_get_string(tlscerts, fingerprint, "signaturealg", NULL);
+        auto_gchar gchar* serialnumber = g_key_file_get_string(tlscerts, fingerprint, "serialnumber", NULL);
+        auto_gchar gchar* subjectname = g_key_file_get_string(tlscerts, fingerprint, "subjectname", NULL);
+        auto_gchar gchar* issuername = g_key_file_get_string(tlscerts, fingerprint, "issuername", NULL);
+        auto_gchar gchar* notbefore = g_key_file_get_string(tlscerts, fingerprint, "start", NULL);
+        auto_gchar gchar* notafter = g_key_file_get_string(tlscerts, fingerprint, "end", NULL);
+        auto_gchar gchar* keyalg = g_key_file_get_string(tlscerts, fingerprint, "keyalg", NULL);
+        auto_gchar gchar* signaturealg = g_key_file_get_string(tlscerts, fingerprint, "signaturealg", NULL);
 
         TLSCertificate* cert = tlscerts_new(fingerprint, version, serialnumber, subjectname, issuername, notbefore,
                                             notafter, keyalg, signaturealg, NULL);
 
-        free(fingerprint);
-        free(serialnumber);
-        free(subjectname);
-        free(issuername);
-        free(notbefore);
-        free(notafter);
-        free(keyalg);
-        free(signaturealg);
-
         res = g_list_append(res, cert);
     }
 
@@ -316,25 +307,16 @@ tlscerts_get_trusted(const char* const fingerprint)
     }
 
     int version = g_key_file_get_integer(tlscerts, fingerprint, "version", NULL);
-    char* serialnumber = g_key_file_get_string(tlscerts, fingerprint, "serialnumber", NULL);
-    char* subjectname = g_key_file_get_string(tlscerts, fingerprint, "subjectname", NULL);
-    char* issuername = g_key_file_get_string(tlscerts, fingerprint, "issuername", NULL);
-    char* notbefore = g_key_file_get_string(tlscerts, fingerprint, "start", NULL);
-    char* notafter = g_key_file_get_string(tlscerts, fingerprint, "end", NULL);
-    char* keyalg = g_key_file_get_string(tlscerts, fingerprint, "keyalg", NULL);
-    char* signaturealg = g_key_file_get_string(tlscerts, fingerprint, "signaturealg", NULL);
+    auto_gchar gchar* serialnumber = g_key_file_get_string(tlscerts, fingerprint, "serialnumber", NULL);
+    auto_gchar gchar* subjectname = g_key_file_get_string(tlscerts, fingerprint, "subjectname", NULL);
+    auto_gchar gchar* issuername = g_key_file_get_string(tlscerts, fingerprint, "issuername", NULL);
+    auto_gchar gchar* notbefore = g_key_file_get_string(tlscerts, fingerprint, "start", NULL);
+    auto_gchar gchar* notafter = g_key_file_get_string(tlscerts, fingerprint, "end", NULL);
+    auto_gchar gchar* keyalg = g_key_file_get_string(tlscerts, fingerprint, "keyalg", NULL);
+    auto_gchar gchar* signaturealg = g_key_file_get_string(tlscerts, fingerprint, "signaturealg", NULL);
 
     TLSCertificate* cert = tlscerts_new(fingerprint, version, serialnumber, subjectname, issuername, notbefore,
                                         notafter, keyalg, signaturealg, NULL);
-
-    free(serialnumber);
-    free(subjectname);
-    free(issuername);
-    free(notbefore);
-    free(notafter);
-    free(keyalg);
-    free(signaturealg);
-
     return cert;
 }