From: Youngjae Cho Date: Thu, 24 Jun 2021 07:37:39 +0000 (+0900) Subject: Fix boolean join considering language property X-Git-Tag: submit/tizen/20210628.062452^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4aa9ca540ca7e3680e8da42a44b0e7453c3bbd1c;p=platform%2Fcore%2Fapi%2Fsystem-info.git Fix boolean join considering language property Boolean value is a string of length LANG_MAX. Each character in the value denotes viability of feature for a specific language. Therefore for joining boolean value, compare each character one by one. Change-Id: Ib9f0256073b731b853b4b3ff6555fbe42507c48d Signed-off-by: Youngjae Cho --- diff --git a/src/system_info.c b/src/system_info.c index 5309c54..7991e89 100644 --- a/src/system_info.c +++ b/src/system_info.c @@ -76,6 +76,9 @@ static void destroy_key_value(gpointer data) static int db_join_value(const char *value_platform, const char *value_hal, const char *type, char *out, int len) { + int i; + bool platform, hal; + if (!value_platform || !value_hal || !type) return SYSTEM_INFO_ERROR_INVALID_PARAMETER; @@ -88,12 +91,14 @@ static int db_join_value(const char *value_platform, const char *value_hal, cons /* If the type is bool type, then * the result is AND of those two value */ - if (value_platform[0] == 'F') - strncpy(out, value_platform, len); - else if (value_hal[0] == 'F') - strncpy(out, value_hal, len); - else - strncpy(out, value_platform, len); + if (len < LANG_MAX || strlen(value_platform) < LANG_MAX || strlen(value_hal) < LANG_MAX) + return SYSTEM_INFO_ERROR_INVALID_PARAMETER; + + for (i = 0; i < LANG_MAX; ++i) { + platform = (value_platform[i] == 'T'); + hal = (value_hal[i] == 'T'); + out[i] = (platform && hal) ? 'T' : 'F'; + } return SYSTEM_INFO_ERROR_NONE; }