Enforce a check on the content parity level

This to avoid that damaged files cause a crash.
This commit is contained in:
Andrea Mazzoleni 2016-07-26 20:56:21 +02:00
parent 0b4aee793a
commit 00e1ca5997

View file

@ -2636,9 +2636,19 @@ static void state_read_content(struct snapraid_state* state, const char* path, S
/* LCOV_EXCL_STOP */
}
if (v_level >= LEV_MAX) {
/* LCOV_EXCL_START */
decoding_error(path, f);
log_fatal("Invalid parity level '%u' in the configuration file!\n", v_level);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
/* auto configure if configuration is missing */
if (state->no_conf && v_level < LEV_MAX && v_level >= state->level)
state->level = v_level + 1;
if (state->no_conf) {
if (v_level >= state->level)
state->level = v_level + 1;
}
/* if we use this parity entry */
if (v_level < state->level) {
@ -2688,9 +2698,17 @@ static void state_read_content(struct snapraid_state* state, const char* path, S
/* LCOV_EXCL_STOP */
}
if (v_level >= LEV_MAX) {
/* LCOV_EXCL_START */
decoding_error(path, f);
log_fatal("Invalid parity level '%u' in the configuration file!\n", v_level);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
/* auto configure if configuration is missing */
if (state->no_conf) {
if (v_level < LEV_MAX && v_level >= state->level)
if (v_level >= state->level)
state->level = v_level + 1;
if (state->parity[v_level].split_mac < v_split_mac)
state->parity[v_level].split_mac = v_split_mac;