pstore: fix use after free
authorMichael Olbrich <m.olbrich@pengutronix.de>
Fri, 6 Sep 2019 13:04:01 +0000 (15:04 +0200)
committerMichael Biebl <biebl@debian.org>
Tue, 19 Nov 2019 08:17:12 +0000 (08:17 +0000)
The memory is still needed in the sd_journal_sendv() after the 'if' block.

(cherry picked from commit 1e19f5ac0d680a63eccae7ef1fc6ce225dca0bbf)
(cherry picked from commit 1b3156edd291e0882d80a695d035dd30521345d1)

Gbp-Pq: Name pstore-fix-use-after-free.patch

src/pstore/pstore.c

index c760b3e899ce36ee3cc4844166742861d56f19f4..8ffe523830f302c523f2481a32d0f3f39e95918b 100644 (file)
@@ -117,6 +117,7 @@ static int compare_pstore_entries(const void *_a, const void *_b) {
 
 static int move_file(PStoreEntry *pe, const char *subdir) {
         _cleanup_free_ char *ifd_path = NULL, *ofd_path = NULL;
+        _cleanup_free_ void *field = NULL;
         const char *suffix, *message;
         struct iovec iovec[2];
         int n_iovec = 0, r;
@@ -138,7 +139,6 @@ static int move_file(PStoreEntry *pe, const char *subdir) {
         iovec[n_iovec++] = IOVEC_MAKE_STRING(message);
 
         if (pe->content_size > 0) {
-                _cleanup_free_ void *field = NULL;
                 size_t field_size;
 
                 field_size = strlen("FILE=") + pe->content_size;