From c6983c0f5f9f5b4ad7c313dd5e24ceba34e908fd Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 2 Oct 2021 06:25:07 +0300 Subject: [PATCH 36/36] cma_get_parameter(): Check attribute format version, don't assert() it See osdn #42898 Signed-off-by: Marko Lindqvist --- client/agents/cma_core.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/client/agents/cma_core.c b/client/agents/cma_core.c index 552cef4e26..eb089b2021 100644 --- a/client/agents/cma_core.c +++ b/client/agents/cma_core.c @@ -80,6 +80,8 @@ #define SAVED_PARAMETER_SIZE 29 +#define CMA_ATTR_VERSION 2 + /* * Misc statistic to analyze performance. */ @@ -586,7 +588,11 @@ bool cma_get_parameter(enum attr_city attr, int city_id, dio_input_init(&din, buffer, len); dio_get_uint8_raw(&din, &version); - fc_assert_ret_val(version == 2, FALSE); + if (version != CMA_ATTR_VERSION) { + log_error("CMA data has a wrong version %d (expected %d)", + version, CMA_ATTR_VERSION); + return FALSE; + } /* Initialize the parameter (includes some AI-only fields that aren't * touched below). */ @@ -618,7 +624,7 @@ void cma_set_parameter(enum attr_city attr, int city_id, dio_output_init(&dout, buffer, sizeof(buffer)); - dio_put_uint8_raw(&dout, 2); + dio_put_uint8_raw(&dout, CMA_ATTR_VERSION); output_type_iterate(i) { dio_put_sint16_raw(&dout, parameter->minimal_surplus[i]); -- 2.33.0