Disallow hashsize 2 and enforce a minimum hash size of 4 bytes
Some checks are pending
Build / build-mac (push) Waiting to run
Build / build-linux (push) Waiting to run
Build / build-arm32 (push) Waiting to run
Build / build-win (push) Waiting to run
Build / build-freebsd (push) Waiting to run
Build / build-musl (push) Waiting to run
CodeQL Advanced / Analyze (c-cpp) (push) Waiting to run
CodeQL Advanced / Analyze (actions) (push) Waiting to run

This commit is contained in:
Andrea Mazzoleni 2026-09-08 13:31:02 +02:00
parent fe2a07fc78
commit 7ba5f63d2d

View file

@ -742,7 +742,13 @@ void state_config(struct snapraid_state* state, const char* path, const char* co
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (hash_size < 2) {
if (hash_size == 2) {
/* LCOV_EXCL_START */
log_fatal(EUSER, "Unsupported 'hashsize 2' specification in '%s' at line %u! The minimum supported hash size is 4.\n", path, line);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (hash_size < 4) {
/* LCOV_EXCL_START */
log_fatal(EUSER, "Too small 'hashsize' specification in '%s' at line %u\n", path, line);
exit(EXIT_FAILURE);
@ -3184,7 +3190,15 @@ static void state_read_content(struct snapraid_state* state, const char* path, S
/* LCOV_EXCL_STOP */
}
if (hash_size < 2 || hash_size > HASH_MAX) {
if (hash_size == 2) {
/* LCOV_EXCL_START */
decoding_error(path, f);
log_fatal(ECONTENT, "Unsupported 'hashsize 2' specification in the content file! The minimum supported hash size is 4.\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (hash_size < 4 || hash_size > HASH_MAX) {
/* LCOV_EXCL_START */
decoding_error(path, f);
log_fatal(ECONTENT, "Invalid 'hashsize' specification in the content file!\n");