From 4bbfc1e86b92f71ea76c36c2971f2b8213084a20 Mon Sep 17 00:00:00 2001 From: Sebastien GODARD Date: Sun, 5 Feb 2023 15:16:36 +0100 Subject: [PATCH] sar/sadf: Add a check on file's records headers data 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 --- sa_common.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sa_common.c b/sa_common.c index 44d9d61..a8879e7 100644 --- a/sa_common.c +++ b/sa_common.c @@ -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; } -- 2.40.0