anitazha / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone
65878a
From c10d51e51388a133d1e0a656f9f69c3d2ca79f09 Mon Sep 17 00:00:00 2001
65878a
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
65878a
Date: Wed, 9 Oct 2013 22:13:13 -0400
65878a
Subject: [PATCH] journald: remove rotated file from hashmap when rotation
65878a
 fails
65878a
65878a
Before, when the user journal file was rotated, journal_file_rotate
65878a
could close the old file and fail to open the new file. In that
65878a
case, we would leave the old (deallocated) file in the hashmap.
65878a
On subsequent accesses, we could retrieve this stale entry, leading
65878a
to a segfault.
65878a
65878a
When journal_file_rotate fails with the file pointer set to 0,
65878a
old file is certainly gone, and cannot be used anymore.
65878a
65878a
https://bugzilla.redhat.com/show_bug.cgi?id=890463
65878a
---
65878a
 src/journal/journald-server.c | 4 +++-
65878a
 1 file changed, 3 insertions(+), 1 deletion(-)
65878a
65878a
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
65878a
index 4f47eb1..e03e413 100644
65878a
--- a/src/journal/journald-server.c
65878a
+++ b/src/journal/journald-server.c
65878a
@@ -321,8 +321,10 @@ void server_rotate(Server *s) {
65878a
                 if (r < 0)
65878a
                         if (f)
65878a
                                 log_error("Failed to rotate %s: %s", f->path, strerror(-r));
65878a
-                        else
65878a
+                        else {
65878a
                                 log_error("Failed to create user journal: %s", strerror(-r));
65878a
+                                hashmap_remove(s->user_journals, k);
65878a
+                        }
65878a
                 else {
65878a
                         hashmap_replace(s->user_journals, k, f);
65878a
                         server_fix_perms(s, f, PTR_TO_UINT32(k));