From 532d62b99af152e61058d8d52ce3e513d7b6a5f4 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 2 Oct 2021 06:34:31 +0300 Subject: [PATCH 9/9] 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 50f95eb919..e39ee9cc72 100644 --- a/client/agents/cma_core.c +++ b/client/agents/cma_core.c @@ -79,6 +79,8 @@ #define SAVED_PARAMETER_SIZE 29 +#define CMA_ATTR_VERSION 2 + /* * Misc statistic to analyze performance. */ @@ -575,7 +577,11 @@ bool cma_get_parameter(enum attr_city attr, int city_id, dio_input_init(&din, buffer, len); dio_get_uint8(&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). */ @@ -607,7 +613,7 @@ void cma_set_parameter(enum attr_city attr, int city_id, dio_output_init(&dout, buffer, sizeof(buffer)); - dio_put_uint8(&dout, 2); + dio_put_uint8(&dout, CMA_ATTR_VERSION); output_type_iterate(i) { dio_put_sint16(&dout, parameter->minimal_surplus[i]); -- 2.33.0