summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2020-11-09 15:23:32 +0900
committerLennart Poettering <lennart@poettering.net>2020-11-10 13:14:42 +0100
commit41d544a1c124a63f94b571e5ed924c4fb03193bb (patch)
treeb23e3fa5d6ab0f104f9e33a9429f5a8c48e02d04
parentb8aac5014c7dec215bac42007be2ee6ded0d5c56 (diff)
downloadsystemd-41d544a1c124a63f94b571e5ed924c4fb03193bb.tar.gz
journal: refuse skip parameter for sd_journal_next_skip() larger than INT_MAX
Fixes #17502.
-rw-r--r--man/sd_journal_next.xml6
-rw-r--r--src/journal/sd-journal.c1
2 files changed, 4 insertions, 3 deletions
diff --git a/man/sd_journal_next.xml b/man/sd_journal_next.xml
index 5f476fe3df..5608331737 100644
--- a/man/sd_journal_next.xml
+++ b/man/sd_journal_next.xml
@@ -78,9 +78,9 @@
the read pointer back one entry.</para>
<para><function>sd_journal_next_skip()</function> and
- <function>sd_journal_previous_skip()</function> advance/set back
- the read pointer by multiple entries at once, as specified in the
- <varname>skip</varname> parameter.</para>
+ <function>sd_journal_previous_skip()</function> advance/set back the read pointer by multiple
+ entries at once, as specified in the <varname>skip</varname> parameter. The <varname>skip</varname>
+ parameter must be less than or equal to 2147483647 (2^31-1).</para>
<para>The journal is strictly ordered by reception time, and hence
advancing to the next entry guarantees that the entry then
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
index dbbf919b75..cb1ab88ca5 100644
--- a/src/journal/sd-journal.c
+++ b/src/journal/sd-journal.c
@@ -883,6 +883,7 @@ static int real_journal_next_skip(sd_journal *j, direction_t direction, uint64_t
assert_return(j, -EINVAL);
assert_return(!journal_pid_changed(j), -ECHILD);
+ assert_return(skip <= INT_MAX, -ERANGE);
if (skip == 0) {
/* If this is not a discrete skip, then at least