1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-10 01:17:44 +03:00

journal: Skip data objects with invalid offsets

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 df207ccb7b)
This commit is contained in:
Daan De Meyer 2022-01-12 14:44:50 +00:00 committed by Zbigniew Jędrzejewski-Szmek
parent 19fbd7764d
commit 556f46aa3b

View File

@ -2303,8 +2303,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)
@ -2448,8 +2448,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)