Change the BLOCK_HASH_SIZE type to avoid potential overflow

This commit is contained in:
Andrea Mazzoleni 2026-05-03 22:29:11 +02:00
parent 6b9459346a
commit fd77444254
7 changed files with 13 additions and 12 deletions

View file

@ -2964,7 +2964,7 @@ static void state_read_content(struct snapraid_state* state, const char* path, S
BLOCK_HASH_SIZE = hash_size;
}
if ((int)hash_size != BLOCK_HASH_SIZE) {
if (hash_size != BLOCK_HASH_SIZE) {
/* LCOV_EXCL_START */
decoding_error(path, f);
log_fatal(EUSER, "Mismatching 'hashsize' specification in the content file!\n");
@ -5659,7 +5659,7 @@ void generate_configuration(const char* path)
printf("blocksize %u\n", state.block_size / KIBI);
printf("\n");
printf("# Use this hashsize\n");
printf("hashsize %u\n", BLOCK_HASH_SIZE);
printf("hashsize %zu\n", BLOCK_HASH_SIZE);
printf("\n");
for (l = 0; l < state.level; ++l) {
printf("# Set the correct path for the %s files\n", lev_name(l));