In asym op, while parsing test interim info, existing buffer of size 256 bytes is not sufficient, hence setting it to maximum that a test would need.
Fixes: 58cc98801eb ("examples/fips_validation: add JSON parsing") Signed-off-by: Gowrishankar Muthukrishnan <gmuthukri...@marvell.com> --- examples/fips_validation/fips_validation.c | 7 ++++--- examples/fips_validation/fips_validation.h | 7 +++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/examples/fips_validation/fips_validation.c b/examples/fips_validation/fips_validation.c index e755654cd0..be0634c3ac 100644 --- a/examples/fips_validation/fips_validation.c +++ b/examples/fips_validation/fips_validation.c @@ -484,7 +484,7 @@ fips_test_parse_one_json_group(void) json_t *param; if (info.interim_callbacks) { - char json_value[256]; + char json_value[FIPS_TEST_JSON_BUF_LEN]; for (i = 0; info.interim_callbacks[i].key != NULL; i++) { param = json_object_get(json_info.json_test_group, info.interim_callbacks[i].key); @@ -493,11 +493,12 @@ fips_test_parse_one_json_group(void) switch (json_typeof(param)) { case JSON_STRING: - snprintf(json_value, 256, "%s", json_string_value(param)); + snprintf(json_value, sizeof(json_value), "%s", + json_string_value(param)); break; case JSON_INTEGER: - snprintf(json_value, 255, "%"JSON_INTEGER_FORMAT, + snprintf(json_value, sizeof(json_value), "%"JSON_INTEGER_FORMAT, json_integer_value(param)); break; diff --git a/examples/fips_validation/fips_validation.h b/examples/fips_validation/fips_validation.h index 4732341dd3..926fe94563 100644 --- a/examples/fips_validation/fips_validation.h +++ b/examples/fips_validation/fips_validation.h @@ -183,6 +183,13 @@ struct xts_interim_data { }; #ifdef USE_JANSSON +/* + * Maximum length of buffer to hold any json string. + * Esp, in asym op, modulo bits decide char buffer size. + * max = (modulo / 4) + */ +#define FIPS_TEST_JSON_BUF_LEN (4096 / 4) + struct fips_test_json_info { /* Information used for reading from json */ json_t *json_root; -- 2.25.1