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