SHA256
1
0
forked from pool/systemd
systemd/0001-journald-remove-rotated-file-from-hashmap-when-rotat.patch

40 lines
1.6 KiB
Diff
Raw Normal View History

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