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