Skip to content

Commit

Permalink
sd-journal: verify monotonic timestamp before assigning result
Browse files Browse the repository at this point in the history
Previously, ret_boot_id was assigned even when the function failed due
to an invalid monotonic timestamp stored for a journal entry.

(cherry picked from commit c9df471)
(cherry picked from commit 6549d31)
  • Loading branch information
yuwata authored and bluca committed May 9, 2024
1 parent 51a9acb commit dc463b3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/libsystemd/sd-journal/sd-journal.c
Original file line number Diff line number Diff line change
Expand Up @@ -2526,9 +2526,7 @@ _public_ int sd_journal_get_monotonic_usec(sd_journal *j, uint64_t *ret, sd_id12
if (r < 0)
return r;

if (ret_boot_id)
*ret_boot_id = o->entry.boot_id;
else {
if (!ret_boot_id) {
sd_id128_t id;

r = sd_id128_get_boot(&id);
Expand All @@ -2545,6 +2543,8 @@ _public_ int sd_journal_get_monotonic_usec(sd_journal *j, uint64_t *ret, sd_id12

if (ret)
*ret = t;
if (ret_boot_id)
*ret_boot_id = o->entry.boot_id;

return 0;
}
Expand Down

0 comments on commit dc463b3

Please sign in to comment.