mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 10:51:54 -04:00
Enforce content file CRC as terminal by rejecting trailing data and terminating parse loop
This commit is contained in:
parent
db34e93936
commit
9ef9155ccf
1 changed files with 14 additions and 1 deletions
|
|
@ -3422,6 +3422,20 @@ static void state_read_content(struct snapraid_state* state, const char* path, S
|
|||
}
|
||||
|
||||
crc_checked = 1;
|
||||
|
||||
/* trailing bytes would lie outside the content boundary verified by the terminal CRC */
|
||||
c = sgetc(f);
|
||||
if (c != EOF) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal(ECONTENT, "Unexpected data after CRC in content file '%s' at offset %" PRIi64 "\n", path, stell(f));
|
||||
log_fatal(ECONTENT, "The content file '%s' is damaged or corrupted!\n", path);
|
||||
log_fatal(ECONTENT, "To recover, rename or delete it and rerun the command.\n");
|
||||
log_fatal(ECONTENT, "SnapRAID will automatically fall back to the next healthy copy.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
break;
|
||||
} else {
|
||||
/* LCOV_EXCL_START */
|
||||
decoding_error(path, f);
|
||||
|
|
@ -6208,4 +6222,3 @@ void state_snapshot_cleanup(struct snapraid_state* state)
|
|||
fssnapshot_unmount(&disk->fss);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue