From 55958b8bc36e1b3a70ee963af6196547637d0899 Mon Sep 17 00:00:00 2001 From: Our Air Quality Date: Tue, 6 Jun 2017 20:56:32 +1000 Subject: [PATCH] sysparam_get_bool: memcpy the binary values out. --- core/sysparam.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/sysparam.c b/core/sysparam.c index 126cfe0..27471a0 100644 --- a/core/sysparam.c +++ b/core/sysparam.c @@ -801,9 +801,13 @@ sysparam_status_t sysparam_get_bool(const char *key, bool *result) { do { if (binary) { if (data_len == 1) { // int8 value - *result = (int8_t)(*buf) ? true : false; + uint8_t value; + memcpy(&value, buf, sizeof(value)); + *result = value ? true : false; } else if (data_len == 4) { // int32 value - *result = (int32_t)(*buf) ? true : false; + uint32_t value; + memcpy(&value, buf, sizeof(value)); + *result = value ? true : false; } else { status = SYSPARAM_PARSEFAILED; }