log: tighten start_magic

This commit is contained in:
Thomas Schoebel-Theuer 2023-03-30 16:13:06 +02:00
parent 15009b1395
commit 1e3df0f96c
2 changed files with 5 additions and 17 deletions

View File

@ -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;

View File

@ -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 */