mirror of
https://github.com/Dasharo/systemd.git
synced 2026-03-06 15:02:31 -08:00
journalctl: fix when --since, --until and --lines are used altogether
This is a follow-up for #26669 (81fb5375b3). After the mentioned commit, we stopped checking if the entry is within the range of --until if --lines is used. However, when --since, --until and --lines=N are used altogether, and the number of lines between --since and --until is smaller than N, we would seek to --since later (f582695107). This breaks the assumption that if --lines is set, the boundary is never exceeded because the counter of outputs gets us covered.
This commit is contained in:
@@ -2567,7 +2567,12 @@ static int run(int argc, char *argv[]) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (arg_until_set && !arg_reverse && arg_lines < 0) {
|
||||
if (arg_until_set && !arg_reverse && (arg_lines < 0 || arg_since_set)) {
|
||||
/* If --lines= is set, we usually rely on the n_shown to tell us
|
||||
* when to stop. However, if --since= is set too, we may end up
|
||||
* having less than --lines= to output. In this case let's also
|
||||
* check if the entry is in range. */
|
||||
|
||||
usec_t usec;
|
||||
|
||||
r = sd_journal_get_realtime_usec(j, &usec);
|
||||
|
||||
Reference in New Issue
Block a user