Fix deserialization of bool with libconfig
diff mbox series

Message ID 1559660953-17552-1-git-send-email-mark.jonas@de.bosch.com
State Changes Requested
Headers show
Series
  • Fix deserialization of bool with libconfig
Related show

Commit Message

'Chmielewski Andreas' via swupdate June 4, 2019, 3:09 p.m. UTC
bootloader_transaction_marker in struct swupdate_cfg
(include/swupdate.h) is a bool. But the deserialization writes an int.
This will taint the following structure element software_set[] if
sizeof(int) > sizeof(bool).

The problem was detected when adding bootloader_transaction_marker=false
to a sw-description file on a NXP i.MX6 containing software collections.
On a NXP i.MX6 sizeof(bool)==1 and sizeof(int)==4.

Signed-off-by: Mark Jonas <mark.jonas@de.bosch.com>
Tested-by: Leo Ruan <tingquan.ruan@cn.bosch.com>
---
 corelib/parsing_library_libconfig.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/corelib/parsing_library_libconfig.c b/corelib/parsing_library_libconfig.c
index 4cd3da2..42685c1 100644
--- a/corelib/parsing_library_libconfig.c
+++ b/corelib/parsing_library_libconfig.c
@@ -34,7 +34,7 @@  void get_value_libconfig(const config_setting_t *e, void *dest)
 		dest = (void *)config_setting_get_string(e);
 		break;
 	case CONFIG_TYPE_BOOL:
-		*(int *)dest = config_setting_get_bool(e);
+		*(bool *)dest = config_setting_get_bool(e);
 		break;
 	case CONFIG_TYPE_FLOAT:
 		*(double *)dest = config_setting_get_float(e);