Skip to content

journalctl -r -n flags incorrectly processed #1596

@ceecko

Description

@ceecko

I'm running version 208 - unfortunately I can't install the latest version but the issues seems to be present in the master as well as of writing.

journalctl --version
systemd 208
+PAM +LIBWRAP +AUDIT +SELINUX +IMA +SYSVINIT +LIBCRYPTSETUP +GCRYPT +ACL +XZ

Consider the following log entries:

2015-01-01 log1
2015-02-02 log2
2015-03-03 log3
2015-04-04 log4

Issuing journalctl -n 2 properly shows this:

2015-03-03 log3
2015-04-04 log4

However issuing journalctl -r -n 2 shows this:

2015-02-02 log2
2015-01-01 log1

This is because in journalctl.c line 2087 skips journal by arg_lines but doesn't take into account arg_reverse. Consequently on line 2153 the journal is read from arg_lines backwards which ultimately skips first arg_lines lines.

The expected output of journalctl -r -n 2 is:

2015-04-04 log4
2015-03-03 log3

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛Programming errors, that need preferential fixingjournal

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions