]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
logs-show: skip journal entry with an invalid timestamp
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 28 Dec 2024 05:09:22 +0000 (14:09 +0900)
committerLuca Boccassi <luca.boccassi@gmail.com>
Tue, 8 Apr 2025 19:52:11 +0000 (20:52 +0100)
Follow-up for 275e6be052e690adcad5d2a557acb9dcb5bedbc6.
Fixes oss-fuzz#385221809 (https://issues.oss-fuzz.com/issues/385221809).
Fixes #35737.

(cherry picked from commit f19f640513cf3ededdf1f5cc6f00efca27efc61f)
(cherry picked from commit 65dac0aca471a0ae1c7c9bba849653291623ce2e)

src/shared/logs-show.c
test/fuzz/fuzz-journal-remote/oss-fuzz-385221809 [new file with mode: 0644]

index 153a4110ce6e90bbd805b6cfce2dedc83f32e69b..30055814d2c5318e73fdbac011c94c82a2a611b6 100644 (file)
@@ -333,7 +333,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);
 
@@ -372,7 +372,7 @@ 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.");
 
         if (IN_SET(mode, OUTPUT_SHORT_FULL, OUTPUT_WITH_UNIT)) {
                 const char *k;
@@ -382,8 +382,7 @@ static int output_timestamp_realtime(
                 else
                         k = format_timestamp(buf, sizeof(buf), usec);
                 if (!k)
-                        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);
 
         } else {
                 struct tm tm;
@@ -609,6 +608,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 (file)
index 0000000..8bb473a
Binary files /dev/null and b/test/fuzz/fuzz-journal-remote/oss-fuzz-385221809 differ