From 1e3df0f96cf492af239358d317509f022373ad4d Mon Sep 17 00:00:00 2001 From: Thomas Schoebel-Theuer Date: Thu, 30 Mar 2023 16:13:06 +0200 Subject: [PATCH] log: tighten start_magic --- kernel/lib_log.c | 21 ++++----------------- kernel/mars_errno.h | 1 + 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/kernel/lib_log.c b/kernel/lib_log.c index 29633783..1c011a7d 100644 --- a/kernel/lib_log.c +++ b/kernel/lib_log.c @@ -869,23 +869,10 @@ int log_scan(void *buf, DATA_GET(buf, offset, start_magic); if (unlikely(start_magic != START_MAGIC)) { - /* Skip any zeros without notice. - * This may be used for future extensions, like - * padding at certain places of logfiles. - */ - if (start_magic != 0) { - dirty = true; - classify_bad_magic(start_magic, - &start_byte_code, - mars_error_code); - if (start_byte_code && !*byte_code) { - *byte_code = start_byte_code; - MARS_WRN(SCAN_TXT "found repeated byte pattern 0x%02x", - SCAN_PAR, - start_byte_code); - } - } - continue; + MARS_ERR(SCAN_TXT "bad start magic 0x%llx\n", + SCAN_PAR, start_magic); + RECORD_ERR(-MARS_ERR_SCAN_MAGIC); + return -EBADMSG; } restlen = len - i; diff --git a/kernel/mars_errno.h b/kernel/mars_errno.h index c8c24003..d0f79ca1 100644 --- a/kernel/mars_errno.h +++ b/kernel/mars_errno.h @@ -55,6 +55,7 @@ #define MARS_ERR_SCAN_SEQ_FW 10010 /* Illegal record sequence skip forward */ #define MARS_ERR_SCAN_SEQ_BW 10011 /* Record sequence skip backwards */ #define MARS_ERR_SCAN_SIZE 10012 /* Internal size mismatch */ +#define MARS_ERR_SCAN_MAGIC 10013 /* Unrecognized record */ #define MARS_ERR_MAGIC_BAD 10020 /* Bad magic */ #define MARS_ERR_MAGIC_REPEATED 10021 /* Bad magic has repeated pattern */