The file_magic->header_size should never be outside of the boundary set by
MIN_FILE_HEADER_SIZE and MAX_FILE_HEADER_SIZE.
Should resolve coverity CID 29717 and CID 29719.
};
#define FILE_HEADER_SIZE (sizeof(struct file_header))
-/* The value below is used for sanity check */
+/* The values below are used for sanity check */
+#define MIN_FILE_HEADER_SIZE 0
#define MAX_FILE_HEADER_SIZE 8192
if ((n != FILE_MAGIC_SIZE) ||
(file_magic->sysstat_magic != SYSSTAT_MAGIC) ||
((file_magic->format_magic != FORMAT_MAGIC) && !ignore) ||
- ((file_magic->header_size > MAX_FILE_HEADER_SIZE) && !ignore) ||
+ (file_magic->header_size < MIN_FILE_HEADER_SIZE) ||
+ (file_magic->header_size > MAX_FILE_HEADER_SIZE) ||
((file_magic->header_size < FILE_HEADER_SIZE) && !ignore)) {
/* Display error message and exit */
handle_invalid_sa_file(fd, file_magic, dfile, n);