]> granicus.if.org Git - sysstat/commitdiff
sar/sadf: Add a check on file's records headers data
authorSebastien GODARD <sysstat@users.noreply.github.com>
Sun, 5 Feb 2023 14:16:36 +0000 (15:16 +0100)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Sun, 5 Feb 2023 14:16:36 +0000 (15:16 +0100)
Make sure that the number of seconds since the Epoch saved in the
records's headers are at least 10-digit numbers.

Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
sa_common.c

index 44d9d6152627e186edf12edddc7e39aca2740ad3..a8879e70853df9d8e3f44a41db670376e2bd4e98 100644 (file)
@@ -1586,11 +1586,12 @@ int read_record_hdr(int ifd, void *buffer, struct record_header *record_hdr,
 
                /* Sanity checks */
                if ((record_hdr->record_type <= 0) || (record_hdr->record_type > R_EXTRA_MAX) ||
-                   (record_hdr->hour > 23) || (record_hdr->minute > 59) || (record_hdr->second > 60)) {
+                   (record_hdr->hour > 23) || (record_hdr->minute > 59) || (record_hdr->second > 60) || (record_hdr->ust_time < 1000000000)) {
 #ifdef DEBUG
-                       fprintf(stderr, "%s: record_type=%d HH:MM:SS=%02d:%02d:%02d\n",
+                       fprintf(stderr, "%s: record_type=%d HH:MM:SS=%02d:%02d:%02d (%lld)\n",
                                __FUNCTION__, record_hdr->record_type,
-                               record_hdr->hour, record_hdr->minute, record_hdr->second);
+                               record_hdr->hour, record_hdr->minute, record_hdr->second,
+                               record_hdr->ust_time);
 #endif
                        return 2;
                }