Blame 0004-Fix-double-free-in-write_escrow_data_file.patch

Vojtech Trefny 83aeff
From 7a0e344d0642f76992c943158621d8ee7e5caea3 Mon Sep 17 00:00:00 2001
Vojtech Trefny 83aeff
From: Vojtech Trefny <vtrefny@redhat.com>
Vojtech Trefny 83aeff
Date: Tue, 15 Nov 2022 13:21:25 +0100
Vojtech Trefny 83aeff
Subject: [PATCH 1/2] crypto: Fix GError overwrite from libvolume_key
Vojtech Trefny 83aeff
Vojtech Trefny 83aeff
---
Vojtech Trefny 83aeff
 src/plugins/crypto.c | 7 ++++---
Vojtech Trefny 83aeff
 1 file changed, 4 insertions(+), 3 deletions(-)
Vojtech Trefny 83aeff
Vojtech Trefny 83aeff
diff --git a/src/plugins/crypto.c b/src/plugins/crypto.c
Vojtech Trefny 83aeff
index 35c38410..9064c8e3 100644
Vojtech Trefny 83aeff
--- a/src/plugins/crypto.c
Vojtech Trefny 83aeff
+++ b/src/plugins/crypto.c
Vojtech Trefny 83aeff
@@ -2552,13 +2552,14 @@ static gboolean write_escrow_data_file (struct libvk_volume *volume, struct libv
Vojtech Trefny 83aeff
     GIOChannel *out_file = NULL;
Vojtech Trefny 83aeff
     GIOStatus status = G_IO_STATUS_ERROR;
Vojtech Trefny 83aeff
     gsize bytes_written = 0;
Vojtech Trefny 83aeff
+    GError *l_error = NULL;
Vojtech Trefny 83aeff
 
Vojtech Trefny 83aeff
     packet_data = libvk_volume_create_packet_asymmetric_with_format (volume, &packet_data_size, secret_type, cert,
Vojtech Trefny 83aeff
-                                                                     ui, LIBVK_PACKET_FORMAT_ASYMMETRIC_WRAP_SECRET_ONLY, error);
Vojtech Trefny 83aeff
-
Vojtech Trefny 83aeff
+                                                                     ui, LIBVK_PACKET_FORMAT_ASYMMETRIC_WRAP_SECRET_ONLY, &l_error);
Vojtech Trefny 83aeff
     if (!packet_data) {
Vojtech Trefny 83aeff
         g_set_error (error, BD_CRYPTO_ERROR, BD_CRYPTO_ERROR_ESCROW_FAILED,
Vojtech Trefny 83aeff
-                     "Failed to get escrow data");
Vojtech Trefny 83aeff
+                     "Failed to get escrow data: %s", l_error->message);
Vojtech Trefny 83aeff
+        g_clear_error (&l_error);
Vojtech Trefny 83aeff
         libvk_volume_free (volume);
Vojtech Trefny 83aeff
         return FALSE;
Vojtech Trefny 83aeff
     }
Vojtech Trefny 83aeff
-- 
Vojtech Trefny 83aeff
2.38.1
Vojtech Trefny 83aeff
Vojtech Trefny 83aeff
Vojtech Trefny 83aeff
From 25bf34c4c03e37eb3782dfccf459b9a3f795ddb3 Mon Sep 17 00:00:00 2001
Vojtech Trefny 83aeff
From: Vojtech Trefny <vtrefny@redhat.com>
Vojtech Trefny 83aeff
Date: Wed, 16 Nov 2022 10:26:06 +0100
Vojtech Trefny 83aeff
Subject: [PATCH 2/2] crypto: Fix double free in write_escrow_data_file
Vojtech Trefny 83aeff
Vojtech Trefny 83aeff
---
Vojtech Trefny 83aeff
 src/plugins/crypto.c | 1 -
Vojtech Trefny 83aeff
 1 file changed, 1 deletion(-)
Vojtech Trefny 83aeff
Vojtech Trefny 83aeff
diff --git a/src/plugins/crypto.c b/src/plugins/crypto.c
Vojtech Trefny 83aeff
index 9064c8e3..2086209e 100644
Vojtech Trefny 83aeff
--- a/src/plugins/crypto.c
Vojtech Trefny 83aeff
+++ b/src/plugins/crypto.c
Vojtech Trefny 83aeff
@@ -2560,7 +2560,6 @@ static gboolean write_escrow_data_file (struct libvk_volume *volume, struct libv
Vojtech Trefny 83aeff
         g_set_error (error, BD_CRYPTO_ERROR, BD_CRYPTO_ERROR_ESCROW_FAILED,
Vojtech Trefny 83aeff
                      "Failed to get escrow data: %s", l_error->message);
Vojtech Trefny 83aeff
         g_clear_error (&l_error);
Vojtech Trefny 83aeff
-        libvk_volume_free (volume);
Vojtech Trefny 83aeff
         return FALSE;
Vojtech Trefny 83aeff
     }
Vojtech Trefny 83aeff
 
Vojtech Trefny 83aeff
-- 
Vojtech Trefny 83aeff
2.38.1
Vojtech Trefny 83aeff