From: Yu Watanabe Date: Sat, 28 Dec 2024 05:09:22 +0000 (+0900) Subject: logs-show: skip journal entry with an invalid timestamp X-Git-Tag: v258-rc1~1771^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f19f640513cf3ededdf1f5cc6f00efca27efc61f;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c index 4e7ed0be6fa..41a3a5adc57 100644 --- a/src/shared/logs-show.c +++ b/src/shared/logs-show.c @@ -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; diff --git a/test/fuzz/fuzz-journal-remote/oss-fuzz-385221809 b/test/fuzz/fuzz-journal-remote/oss-fuzz-385221809 new file mode 100644 index 00000000000..8bb473ac56a Binary files /dev/null and b/test/fuzz/fuzz-journal-remote/oss-fuzz-385221809 differ