richardphibel / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
5808e7
From 7f5bfbd5485e1cb779d7568cabb5783651fd9da3 Mon Sep 17 00:00:00 2001
5808e7
From: Michael Olbrich <m.olbrich@pengutronix.de>
5808e7
Date: Fri, 6 Sep 2019 15:04:01 +0200
5808e7
Subject: [PATCH] pstore: fix use after free
5808e7
5808e7
The memory is still needed in the sd_journal_sendv() after the 'if' block.
5808e7
5808e7
(cherry picked from commit 1e19f5ac0d680a63eccae7ef1fc6ce225dca0bbf)
5808e7
5808e7
Related: #2158832
5808e7
---
5808e7
 src/pstore/pstore.c | 2 +-
5808e7
 1 file changed, 1 insertion(+), 1 deletion(-)
5808e7
5808e7
diff --git a/src/pstore/pstore.c b/src/pstore/pstore.c
5808e7
index eb251d61c8..cafb1804c6 100644
5808e7
--- a/src/pstore/pstore.c
5808e7
+++ b/src/pstore/pstore.c
5808e7
@@ -114,6 +114,7 @@ static int compare_pstore_entries(const void *_a, const void *_b) {
5808e7
 
5808e7
 static int move_file(PStoreEntry *pe, const char *subdir) {
5808e7
         _cleanup_free_ char *ifd_path = NULL, *ofd_path = NULL;
5808e7
+        _cleanup_free_ void *field = NULL;
5808e7
         const char *suffix, *message;
5808e7
         struct iovec iovec[2];
5808e7
         int n_iovec = 0, r;
5808e7
@@ -135,7 +136,6 @@ static int move_file(PStoreEntry *pe, const char *subdir) {
5808e7
         iovec[n_iovec++] = IOVEC_MAKE_STRING(message);
5808e7
 
5808e7
         if (pe->content_size > 0) {
5808e7
-                _cleanup_free_ void *field = NULL;
5808e7
                 size_t field_size;
5808e7
 
5808e7
                 field_size = strlen("FILE=") + pe->content_size;