Since 1db0aefe57de ("Enforce type check in sw-description"),
GET_FIELD_INT64() does not assign a config value anymore if the type
detected by libconfig differs. This type check needs to be slightly
relaxed to allow assignment of parsed INT32 values when a INT64 is
expected. Otherwise this would require conversion of the sw-description
in the .swu files which breaks compatiblity with existing update files.
Link:
https://groups.google.com/g/swupdate/c/UeALEHCAusQ
Signed-off-by: Christian Eggers <
ceg...@arri.de>
---
corelib/parsing_library_libconfig.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/corelib/parsing_library_libconfig.c b/corelib/parsing_library_libconfig.c
index ddb79f6fb152..727697448ac4 100644
--- a/corelib/parsing_library_libconfig.c
+++ b/corelib/parsing_library_libconfig.c
@@ -42,8 +42,13 @@ static unsigned int map_field_type(field_type_t type)
static void get_value_libconfig(const config_setting_t *e, void *dest, field_type_t expected_type)
{
int type = config_setting_type(e);
- if (type != map_field_type(expected_type))
- return;
+ if (type != map_field_type(expected_type)) {
+ /* Only allow implicit conversion from INT to INT64 */
+ if (type == CONFIG_TYPE_INT && expected_type == TYPE_INT64)
+ type = CONFIG_TYPE_INT64;
+ else
+ return;
+ }
switch (type) {
case CONFIG_TYPE_INT:
*(int *)dest = config_setting_get_int(e);
--
2.44.1