Revert "Limit the index to the fixed gas mixes"

This reverts commit 328812e95bfe7c6c9d2a8d36c75144f05c7dc9dc.

This turns out to cause fatal parse failures for the cases where the gas
change refers to a manual or bailout gas.

As noted by Jef in that commit, we should likely report those
differently, but in the meantime, at least don't fail the download.

See the original report at [1], and a (at this point still contentious)
bigger change to gas switch reporting at [2].  This revert exists purely
as a "make it at least work for now".

Reported-by: Michael Keller <github@ike.ch>
Link: https://github.com/subsurface/libdc/pull/46#issuecomment-1438313959 [1]
Link: https://github.com/subsurface/libdc/pull/44 [2]
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Linus Torvalds 2023-03-06 12:02:45 -08:00
parent 648651e2d7
commit 8d3271e586

View File

@ -1049,8 +1049,8 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call
return DC_STATUS_DATAFORMAT;
}
unsigned int idx = data[offset];
if (idx < 1 || idx > parser->nfixed) {
ERROR(abstract->context, "Invalid gas mix (%u).", idx);
if (idx < 1 || idx > parser->ngasmixes) {
ERROR(abstract->context, "Invalid gas mix.");
return DC_STATUS_DATAFORMAT;
}
idx--; /* Convert to a zero based index. */