mirror of
https://github.com/systemd/systemd.git
synced 2025-01-06 17:18:12 +03:00
logs-show: skip journal entry with an invalid timestamp (#35774)
Fixes #35737.
This commit is contained in:
commit
156f90cf62
@ -16,6 +16,7 @@
|
||||
#include "path-util.h"
|
||||
#include "rm-rf.h"
|
||||
#include "strv.h"
|
||||
#include "tests.h"
|
||||
#include "tmpfile-util.h"
|
||||
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
@ -50,14 +51,11 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
return r;
|
||||
}
|
||||
|
||||
r = journal_remote_add_source(&s, fdin, (char*) "fuzz-data", false);
|
||||
if (r < 0)
|
||||
return r;
|
||||
ASSERT_OK_POSITIVE(journal_remote_add_source(&s, fdin, (char*) "fuzz-data", false));
|
||||
TAKE_FD(fdin_close);
|
||||
assert(r > 0);
|
||||
|
||||
while (s.active)
|
||||
assert_se(journal_remote_handle_raw_source(NULL, fdin, 0, &s) >= 0);
|
||||
ASSERT_OK(journal_remote_handle_raw_source(NULL, fdin, 0, &s));
|
||||
|
||||
assert_se(close(fdin) < 0 && errno == EBADF); /* Check that the fd is closed already */
|
||||
|
||||
@ -80,11 +78,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
for (OutputMode mode = 0; mode < _OUTPUT_MODE_MAX; mode++) {
|
||||
if (!dev_null)
|
||||
log_info("/* %s */", output_mode_to_string(mode));
|
||||
r = show_journal(dev_null ?: stdout, j, mode, 0, 0, -1, 0, NULL);
|
||||
assert_se(r >= 0);
|
||||
|
||||
r = sd_journal_seek_head(j);
|
||||
assert_se(r >= 0);
|
||||
ASSERT_OK(show_journal(dev_null ?: stdout, j, mode, 0, 0, -1, 0, NULL));
|
||||
ASSERT_OK(sd_journal_seek_head(j));
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -335,7 +335,7 @@ static int output_timestamp_monotonic(
|
||||
assert(previous_boot_id);
|
||||
|
||||
if (!VALID_MONOTONIC(display_ts->monotonic))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "No valid monotonic timestamp available");
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), "No valid monotonic timestamp available, skipping showing journal entry.");
|
||||
|
||||
written_chars += fprintf(f, "[%5"PRI_USEC".%06"PRI_USEC, display_ts->monotonic / USEC_PER_SEC, display_ts->monotonic % USEC_PER_SEC);
|
||||
|
||||
@ -375,15 +375,14 @@ static int output_timestamp_realtime(
|
||||
assert(j);
|
||||
|
||||
if (!VALID_REALTIME(usec))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "No valid realtime timestamp available.");
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), "No valid realtime timestamp available, skipping showing journal entry.");
|
||||
|
||||
switch (mode) {
|
||||
|
||||
case OUTPUT_SHORT_FULL:
|
||||
case OUTPUT_WITH_UNIT: {
|
||||
if (!format_timestamp_style(buf, sizeof(buf), usec, flags & OUTPUT_UTC ? TIMESTAMP_UTC : TIMESTAMP_PRETTY))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Failed to format timestamp: %" PRIu64, usec);
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), "Failed to format timestamp (%"PRIu64"), skipping showing journal entry.", usec);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -623,6 +622,8 @@ static int output_short(
|
||||
parse_display_realtime(j, realtime, monotonic, &usec);
|
||||
r = output_timestamp_realtime(f, j, mode, flags, usec);
|
||||
}
|
||||
if (r == -EINVAL)
|
||||
return 0;
|
||||
if (r < 0)
|
||||
return r;
|
||||
n += r;
|
||||
|
BIN
test/fuzz/fuzz-journal-remote/oss-fuzz-385221809
Normal file
BIN
test/fuzz/fuzz-journal-remote/oss-fuzz-385221809
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user