mirror of
https://github.com/HDFGroup/hdf5.git
synced 2026-09-25 04:09:44 +03:00
fix(tfilter2): revert >= boundary check and skip deflate test when zlib absent
Two bugs caused H5TEST-tfilter2 to fail on BSD and non-zlib CI builds: 1. H5Zconfig.c: The review changed strlen(params) > H5Z_CONFIG_STRING_MAX to >=, which incorrectly rejected strings of exactly H5Z_CONFIG_STRING_MAX bytes. The public contract (and test_config_string_max_boundary) accept strings up to and including H5Z_CONFIG_STRING_MAX characters. Reverted to >. 2. test/tfilter2.c: test_config_string_max_boundary called H5Pappend_filter with H5Z_FILTER_DEFLATE without first checking availability. On CI builds without zlib the filter lookup fails with "filter not found" before the length check runs. Added H5Zfilter_avail guard; the test is now SKIPPED on non-zlib builds.
This commit is contained in:
+2
-2
@@ -286,7 +286,7 @@ H5Z__toml_parse_params(const char *params, toml_result_t *tr_out, toml_datum_t *
|
||||
* H5Z_CONFIG_STRING_MAX, but enforce it here too so that the
|
||||
* downstream `len * 8` worst-case allocation in H5Z__rewrite_hexfloats
|
||||
* cannot overflow size_t. */
|
||||
if (params && strlen(params) >= H5Z_CONFIG_STRING_MAX)
|
||||
if (params && strlen(params) > H5Z_CONFIG_STRING_MAX)
|
||||
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
|
||||
"filter parameter string exceeds H5Z_CONFIG_STRING_MAX (%d bytes)",
|
||||
H5Z_CONFIG_STRING_MAX);
|
||||
@@ -408,7 +408,7 @@ H5Z__config_validate_keys(const char *params, const char *const *known_keys)
|
||||
if (!params || *params == '\0')
|
||||
HGOTO_DONE(SUCCEED);
|
||||
|
||||
if (strlen(params) >= H5Z_CONFIG_STRING_MAX)
|
||||
if (strlen(params) > H5Z_CONFIG_STRING_MAX)
|
||||
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
|
||||
"filter parameter string exceeds H5Z_CONFIG_STRING_MAX (%d bytes)",
|
||||
H5Z_CONFIG_STRING_MAX);
|
||||
|
||||
+12
-4
@@ -1778,13 +1778,21 @@ error:
|
||||
static int
|
||||
test_config_string_max_boundary(void)
|
||||
{
|
||||
hid_t dcpl = H5I_INVALID_HID;
|
||||
char *ok_str = NULL;
|
||||
const char prefix[] = "level = 6";
|
||||
size_t prefix_len = sizeof(prefix) - 1;
|
||||
hid_t dcpl = H5I_INVALID_HID;
|
||||
char *ok_str = NULL;
|
||||
const char prefix[] = "level = 6";
|
||||
size_t prefix_len = sizeof(prefix) - 1;
|
||||
herr_t ret;
|
||||
htri_t deflate_avail;
|
||||
|
||||
TESTING("H5Pappend_filter: param string == H5Z_CONFIG_STRING_MAX is accepted");
|
||||
/* Deflate (zlib) required as the test filter — skip if not compiled in */
|
||||
if ((deflate_avail = H5Zfilter_avail(H5Z_FILTER_DEFLATE)) < 0)
|
||||
TEST_ERROR;
|
||||
if (!deflate_avail) {
|
||||
SKIPPED();
|
||||
return 0;
|
||||
}
|
||||
if (NULL == (ok_str = (char *)malloc(H5Z_CONFIG_STRING_MAX + 1)))
|
||||
TEST_ERROR;
|
||||
/* Valid TOML string of exactly H5Z_CONFIG_STRING_MAX bytes:
|
||||
|
||||
Reference in New Issue
Block a user