1
0
mirror of https://github.com/systemd/systemd.git synced 2025-03-03 16:58:37 +03:00

logs-show: skip journal entry with an invalid timestamp

Follow-up for 275e6be052e690adcad5d2a557acb9dcb5bedbc6.
Fixes oss-fuzz#385221809 (https://issues.oss-fuzz.com/issues/385221809).
Fixes #35737.
This commit is contained in:
Yu Watanabe 2024-12-28 14:09:22 +09:00
parent f587da03c2
commit f19f640513
2 changed files with 5 additions and 4 deletions

View File

@ -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;

Binary file not shown.