}
}
+bool __check_strlcat(char *dest, const char *src, const int size)
+{
+ return (g_strlcat(dest, src, size) >= (gsize) size) ? true : false;
+}
+
+void __print_warning_msg_truncated()
+{
+ __color_to_bold_yellow();
+ printf("\nWarning: Concated message was truncated\n");
+ __color_to_origin();
+}
+
/* shows error_message returned by privilege_manager_verify_privilege() */
void __print_error_message(char *error_message)
{
memset(err_type, 0, err_type_size*sizeof(char));
if (strstr(error_message, "DEPRECATED") != NULL)
- g_strlcat(err_type, "PRVMGR_ERR_DEPRECATED_PRIVILEGE ", err_type_size);
+ if (__check_strlcat(err_type, "PRVMGR_ERR_DEPRECATED_PRIVILEGE ", err_type_size))
+ __print_warning_msg_truncated();
if (strstr(error_message, "NO_EXIST") != NULL)
- g_strlcat(err_type, "PRVMGR_ERR_NO_EXIST_PRIVILEGE ", err_type_size);
+ if (__check_strlcat(err_type, "PRVMGR_ERR_NO_EXIST_PRIVILEGE ", err_type_size))
+ __print_warning_msg_truncated();
if (strstr(error_message, "MISMATCHED") != NULL)
- g_strlcat(err_type, "PRVMGR_ERR_MISMACHED_PRIVILEGE_LEVEL ", err_type_size);
+ if (__check_strlcat(err_type, "PRVMGR_ERR_MISMACHED_PRIVILEGE_LEVEL ", err_type_size))
+ __print_warning_msg_truncated();
if (strstr(error_message, "INVALID_PARAMETER") != NULL)
- g_strlcat(err_type, "PRVMGR_ERR_INVALID_PARAMETER ", err_type_size);
+ if (__check_strlcat(err_type, "PRVMGR_ERR_INVALID_PARAMETER ", err_type_size))
+ __print_warning_msg_truncated();
if (strstr(error_message, "banned") != NULL)
- g_strlcat(err_type, "PRVMGR_ERR_USING_BANNED_PRIVILEGE ", err_type_size);
+ if (__check_strlcat(err_type, "PRVMGR_ERR_USING_BANNED_PRIVILEGE ", err_type_size))
+ __print_warning_msg_truncated();
if (strlen(err_type) == 0) {
fail_cnt++;
- g_strlcat(err_type, "test failed - unknown error type", err_type_size);
+ if (__check_strlcat(err_type, "test failed - unknown error type", err_type_size))
+ __print_warning_msg_truncated();
+
__color_to_red();
} else {
__color_to_blue();