Fix boolean join considering language property 14/260414/5 accepted/tizen/unified/20210629.130213 submit/tizen/20210628.062452
authorYoungjae Cho <y0.cho@samsung.com>
Thu, 24 Jun 2021 07:37:39 +0000 (16:37 +0900)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Mon, 28 Jun 2021 03:04:09 +0000 (03:04 +0000)
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 <y0.cho@samsung.com>
src/system_info.c

index 5309c54..7991e89 100644 (file)
@@ -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;
 }