anitazha / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone

Blame SOURCES/0018-journal-remote-fix-client_cert-memory-leak.patch

803fb7
From 0488761858a3bfbf06a25fbf3bc0e28fdfc28234 Mon Sep 17 00:00:00 2001
803fb7
From: Michal Schmidt <mschmidt@redhat.com>
803fb7
Date: Tue, 17 Feb 2015 10:36:57 +0100
803fb7
Subject: [PATCH] journal-remote: fix client_cert memory leak
803fb7
803fb7
Found by Valgrind while testing the previous memory leak fix.
803fb7
803fb7
(cherry picked from commit 32c3d7144cf9a5c8c03761d7f198142ca0f5f7b8)
803fb7
---
803fb7
 src/journal-remote/microhttpd-util.c | 6 +++++-
803fb7
 1 file changed, 5 insertions(+), 1 deletion(-)
803fb7
803fb7
diff --git a/src/journal-remote/microhttpd-util.c b/src/journal-remote/microhttpd-util.c
803fb7
index de9c6ab32..a95fff18f 100644
803fb7
--- a/src/journal-remote/microhttpd-util.c
803fb7
+++ b/src/journal-remote/microhttpd-util.c
803fb7
@@ -239,10 +239,14 @@ static int get_auth_dn(gnutls_x509_crt_t client_cert, char **buf) {
803fb7
         return 0;
803fb7
 }
803fb7
 
803fb7
+static inline void gnutls_x509_crt_deinitp(gnutls_x509_crt_t *p) {
803fb7
+        gnutls_x509_crt_deinit(*p);
803fb7
+}
803fb7
+
803fb7
 int check_permissions(struct MHD_Connection *connection, int *code, char **hostname) {
803fb7
         const union MHD_ConnectionInfo *ci;
803fb7
         gnutls_session_t session;
803fb7
-        gnutls_x509_crt_t client_cert;
803fb7
+        _cleanup_(gnutls_x509_crt_deinitp) gnutls_x509_crt_t client_cert = NULL;
803fb7
         _cleanup_free_ char *buf = NULL;
803fb7
         int r;
803fb7