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;
/* 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;
}