1
0
mirror of https://github.com/systemd/systemd.git synced 2025-03-31 14:50:15 +03:00

Avoid forever loop for journalctl --list-boots command (#4278)

When date is changed in system to future and normal user logs to new journal file, and then date is changed back to present time, the "journalctl --list-boot" command goes to forever loop. This commit tries to fix this problem by checking first the boot id list if the found boot id was already in that list. If it is found, then stopping the boot id find loop.
This commit is contained in:
hese10 2016-10-12 19:40:28 +03:00 committed by Lennart Poettering
parent 63b0a24b56
commit ec02a6c90a

View File

@ -1112,7 +1112,7 @@ static int get_boots(
bool skip_once;
int r, count = 0;
BootId *head = NULL, *tail = NULL;
BootId *head = NULL, *tail = NULL, *id;
const bool advance_older = boot_id && offset <= 0;
sd_id128_t previous_boot_id;
@ -1203,6 +1203,13 @@ static int get_boots(
break;
}
} else {
LIST_FOREACH(boot_list, id, head) {
if (sd_id128_equal(id->id, current->id)) {
/* boot id already stored, something wrong with the journal files */
/* exiting as otherwise this problem would cause forever loop */
goto finish;
}
}
LIST_INSERT_AFTER(boot_list, head, tail, current);
tail = current;
current = NULL;