journal: refuse skip parameter for sd_journal_next_skip() larger than INT_MAX

Fixes #17502.
This commit is contained in:
Yu Watanabe 2020-11-09 15:23:32 +09:00 committed by Lennart Poettering
parent b8aac5014c
commit 41d544a1c1
2 changed files with 4 additions and 3 deletions

View File

@ -78,9 +78,9 @@
the read pointer back one entry.</para> the read pointer back one entry.</para>
<para><function>sd_journal_next_skip()</function> and <para><function>sd_journal_next_skip()</function> and
<function>sd_journal_previous_skip()</function> advance/set back <function>sd_journal_previous_skip()</function> advance/set back the read pointer by multiple
the read pointer by multiple entries at once, as specified in the entries at once, as specified in the <varname>skip</varname> parameter. The <varname>skip</varname>
<varname>skip</varname> parameter.</para> parameter must be less than or equal to 2147483647 (2^31-1).</para>
<para>The journal is strictly ordered by reception time, and hence <para>The journal is strictly ordered by reception time, and hence
advancing to the next entry guarantees that the entry then advancing to the next entry guarantees that the entry then

View File

@ -883,6 +883,7 @@ static int real_journal_next_skip(sd_journal *j, direction_t direction, uint64_t
assert_return(j, -EINVAL); assert_return(j, -EINVAL);
assert_return(!journal_pid_changed(j), -ECHILD); assert_return(!journal_pid_changed(j), -ECHILD);
assert_return(skip <= INT_MAX, -ERANGE);
if (skip == 0) { if (skip == 0) {
/* If this is not a discrete skip, then at least /* If this is not a discrete skip, then at least