]> 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)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 28 Dec 2024 05:13:39 +0000 (14:13 +0900)
Follow-up for 275e6be052e690adcad5d2a557acb9dcb5bedbc6.
Fixes oss-fuzz#385221809 (https://issues.oss-fuzz.com/issues/385221809).
Fixes #35737.

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

index 4e7ed0be6fa09518da7fb6adb927c64050b81453..41a3a5adc57cadfb9b3035f7cabb6d6878a694e3 100644 (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;
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