summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaan De Meyer <daan.j.demeyer@gmail.com>2022-01-12 14:44:50 +0000
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-01-12 22:26:26 +0100
commitbf022f9f4841368bb84372ee5605ce5c0f936c79 (patch)
treef9fd3110637174f7a7314897ca7e2c01d05a9343
parent5d3466ec91b05853b815db509b901e6a6d5f4db4 (diff)
downloadsystemd-249.9.tar.gz
journal: Skip data objects with invalid offsetsv249.9
We already skip invalid objects, but don't yet skip invalid offsets. Let's skip these as well to improve robustness when we're dealing with corrupted journals. Before: ``` ➜ systemd git:(main) build/journalctl -r -n 5 --file ~/Downloads/system@0005d2b275abaaf8-f243a2818cb39b98.journal_ Failed to get journal fields: Cannot assign requested address -- No entries -- ``` After: ``` ➜ systemd git:(main) ✗ build/journalctl -r -n 5 --file ~/Downloads/system@0005d2b275abaaf8-f243a2818cb39b98.journal_ Dec 09 08:32:38 snowball3 NetworkManager[911]: <info> [1639038758.1464] device (wlp1s0): supplicant interface state: scanning -> authenticating Dec 09 08:32:38 snowball3 kernel: wlp1s0: send auth to ec:a9:40:79:fb:ad (try 1/3) Dec 09 08:32:38 snowball3 kernel: wlp1s0: authenticate with ec:a9:40:79:fb:ad Dec 09 08:32:38 snowball3 wpa_supplicant[1003]: wlp1s0: SME: Trying to authenticate with ec:a9:40:79:fb:ad (SSID='UPC949397B' freq=5500 MHz) ``` (cherry picked from commit df207ccb7be02b1ca6bdd0a2066a898e5b24ee86) (cherry picked from commit 556f46aa3b17f4ed6768521137405297c8a99d35)
-rw-r--r--src/libsystemd/sd-journal/sd-journal.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/libsystemd/sd-journal/sd-journal.c b/src/libsystemd/sd-journal/sd-journal.c
index dd28b8008f..3cdc629a8d 100644
--- a/src/libsystemd/sd-journal/sd-journal.c
+++ b/src/libsystemd/sd-journal/sd-journal.c
@@ -2310,8 +2310,8 @@ _public_ int sd_journal_get_data(sd_journal *j, const char *field, const void **
p = le64toh(o->entry.items[i].object_offset);
le_hash = o->entry.items[i].hash;
r = journal_file_move_to_object(f, OBJECT_DATA, p, &d);
- if (r == -EBADMSG) {
- log_debug("Entry item %"PRIu64" data object is bad, skipping over it.", i);
+ if (IN_SET(r, -EADDRNOTAVAIL, -EBADMSG)) {
+ log_debug_errno(r, "Entry item %"PRIu64" data object is bad, skipping over it: %m", i);
continue;
}
if (r < 0)
@@ -2455,8 +2455,8 @@ _public_ int sd_journal_enumerate_data(sd_journal *j, const void **data, size_t
p = le64toh(o->entry.items[j->current_field].object_offset);
le_hash = o->entry.items[j->current_field].hash;
r = journal_file_move_to_object(f, OBJECT_DATA, p, &o);
- if (r == -EBADMSG) {
- log_debug("Entry item %"PRIu64" data object is bad, skipping over it.", j->current_field);
+ if (IN_SET(r, -EADDRNOTAVAIL, -EBADMSG)) {
+ log_debug_errno(r, "Entry item %"PRIu64" data object is bad, skipping over it: %m", j->current_field);
continue;
}
if (r < 0)