Reject a content file with the same disk name in two 'M' records
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-11-26 10:16:58 +01:00
parent 2571cce6d5
commit ffd9e2bbff

View file

@ -3682,6 +3682,22 @@ static void state_read_content(struct snapraid_state* state, const char* path, S
/* LCOV_EXCL_STOP */
}
/*
* Reject the same disk name twice. The maps keep the content file
* names until the end of the parsing, so this compares content names.
*/
for (tommy_node* j = tommy_list_head(&state->maplist); j != 0; j = j->next) {
struct snapraid_map* other = j->data;
if (pathcmp(other->name, buffer) == 0) {
/* LCOV_EXCL_START */
decoding_error(path, f);
log_fatal(ECONTENT, "Internal inconsistency: Field 'M' duplicate disk name '%s' in the content file!\n", buffer);
os_abort();
/* LCOV_EXCL_STOP */
}
}
/* find the disk */
disk = find_disk_by_name(state, buffer);
if (!disk) {