found_pos = strstr(found_pos, input_old_string);
}
- EM_SAFE_STRCAT(result_buffer, cursor_of_source_string);
+ EM_SAFE_STRNCAT(result_buffer, cursor_of_source_string, buffer_length - EM_SAFE_STRLEN(result_buffer) - 1);
EM_SAFE_FREE(*input_source_string);
*input_source_string = result_buffer;
((_src) && (_dest))? strncpy(_dest, _src, _size) : NULL;\
})
-#define EM_SAFE_STRCAT(dest, src) \
- ({\
- char* _dest = dest;\
- char* _src = src;\
- ((_src) && (_dest))? strcat(_dest, _src) : NULL;\
- })
-
#define EM_SAFE_STRNCAT(dest, src, size) \
({\
err = EMAIL_ERROR_OUT_OF_MEMORY;
goto FINISH_OFF;
}
- EM_SAFE_STRNCAT(*output_server_capability_string,smtp_capability_string , (server_capability_string_length + 1) - EM_SAFE_STRLEN(*output_server_capability_string)- 1);
- EM_SAFE_STRCAT(*output_server_capability_string, imap_capability_string);
+ EM_SAFE_STRNCAT(*output_server_capability_string, smtp_capability_string, (server_capability_string_length + 1) - EM_SAFE_STRLEN(*output_server_capability_string) - 1);
+ EM_SAFE_STRNCAT(*output_server_capability_string, imap_capability_string, (server_capability_string_length + 1) - EM_SAFE_STRLEN(*output_server_capability_string) - 1);
EM_DEBUG_LOG("%s", *output_server_capability_string);
}
}
if (temp_emailaddr && email_address) {
if (mail_id == 0) { /* if mail_id is 0, return only contact info without saving contact info to DB */
/* snprintf(temp_emailaddr, 400, "%s", contact_info->email_address); */
- EM_SAFE_STRCAT(temp_emailaddr, email_address);
+ EM_SAFE_STRNCAT(temp_emailaddr, email_address, address_length - EM_SAFE_STRLEN(temp_emailaddr) - 1);
if (addr->next != NULL)
- EM_SAFE_STRCAT(temp_emailaddr, ", ");
+ EM_SAFE_STRNCAT(temp_emailaddr, ", ", address_length - EM_SAFE_STRLEN(temp_emailaddr) - 1);
EM_DEBUG_LOG_SEC(">>>> TEMP EMail Address [ %s ] ", temp_emailaddr);
} else { /* save only the first address information - 09-SEP-2010 */
if (is_saved == 0) {
is_saved = 1;
/* snprintf(temp_emailaddr, 400, "%s", contact_info->email_address); */
- EM_SAFE_STRCAT(temp_emailaddr, email_address);
+ EM_SAFE_STRNCAT(temp_emailaddr, email_address, address_length - EM_SAFE_STRLEN(temp_emailaddr) - 1);
/*
if (addr->next != NULL)
- EM_SAFE_STRCAT(temp_emailaddr, ", ");
+ EM_SAFE_STRNCAT(temp_emailaddr, ", ", address_length - EM_SAFE_STRLEN(temp_emailaddr) - 1);
*/
EM_DEBUG_LOG_SEC(">>>> TEMP EMail Address [ %s ] ", temp_emailaddr);
}
*input_exit_flag = 1;
break;
} else {
- EM_SAFE_STRCAT(input_result_buffer, " ");
+ EM_SAFE_STRNCAT(input_result_buffer, " ", input_result_buffer_length - EM_SAFE_STRLEN(input_result_buffer) - 1);
continue;
}
}
if (remain_str) {
char *replaced_string = NULL;
replaced_string = reg_replace_new(remain_str, "[ \t\r\n\v\f]+", " ");
- EM_SAFE_STRCAT(input_result_buffer, replaced_string);
+ EM_SAFE_STRNCAT(input_result_buffer, replaced_string, input_result_buffer_length - EM_SAFE_STRLEN(input_result_buffer) - 1);
EM_SAFE_FREE(replaced_string);
free(remain_str);
}
if (temp_content_string) {
char *replaced_string = NULL;
replaced_string = reg_replace_new(temp_content_string, "[ \t\r\n\v\f]+", " ");
- EM_SAFE_STRCAT(input_result_buffer, replaced_string);
+ EM_SAFE_STRNCAT(input_result_buffer, replaced_string, input_result_buffer_length - EM_SAFE_STRLEN(input_result_buffer) - 1);
EM_SAFE_FREE(replaced_string);
free(temp_content_string);
}
EMSTORAGE_START_READ_TRANSACTION(input_transaction);
SNPRINTF(sql_query_string, query_size, "SELECT COUNT(*) FROM mail_tbl");
- EM_SAFE_STRCAT(sql_query_string, (char*)input_conditional_clause);
+ EM_SAFE_STRNCAT(sql_query_string, (char*)input_conditional_clause, query_size - EM_SAFE_STRLEN(sql_query_string) - 1);
if (output_total_mail_count) {
EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
}
if (output_unseen_mail_count) {
- EM_SAFE_STRCAT(sql_query_string, " AND flags_seen_field = 0 ");
+ EM_SAFE_STRNCAT(sql_query_string, " AND flags_seen_field = 0 ", query_size - EM_SAFE_STRLEN(sql_query_string) - 1);
EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, NULL, NULL, NULL), rc);
EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
/* Composing query */
SNPRINTF_OFFSET(sql_query_string, cur_query, query_size, "SELECT mail_id FROM mail_tbl ");
- EM_SAFE_STRCAT(sql_query_string, (char*)input_conditional_clause);
+ EM_SAFE_STRNCAT(sql_query_string, (char*)input_conditional_clause, query_size - EM_SAFE_STRLEN(sql_query_string) - 1);
EM_DEBUG_LOG_SEC("query[%s].", sql_query_string);
sqlite3_snprintf(query_size, sql_query_string, sql_format, stripped_subject, mail_tbl->mailbox_id);
if (account_id > 0)
- strcat(sql_query_string, sql_account);
+ EM_SAFE_STRNCAT(sql_query_string, sql_account, query_size - EM_SAFE_STRLEN(sql_query_string) - 1);
strcat(sql_query_string, sql_format_order_by);
strcat(sql_query_string, ";");
switch (input_sorting_rule->sort_order) {
case EMAIL_SORT_ORDER_ASCEND:
- EM_SAFE_STRCAT(result_rule_string, " ASC ");
+ EM_SAFE_STRNCAT(result_rule_string, " ASC ", QUERY_SIZE - EM_SAFE_STRLEN(result_rule_string) - 1);
break;
case EMAIL_SORT_ORDER_DESCEND:
- EM_SAFE_STRCAT(result_rule_string, " DESC ");
+ EM_SAFE_STRNCAT(result_rule_string, " DESC ", QUERY_SIZE - EM_SAFE_STRLEN(result_rule_string) - 1);
break;
case EMAIL_SORT_ORDER_NOCASE_ASCEND:
- EM_SAFE_STRCAT(result_rule_string, " COLLATE NOCASE ASC ");
+ EM_SAFE_STRNCAT(result_rule_string, " COLLATE NOCASE ASC ", QUERY_SIZE - EM_SAFE_STRLEN(result_rule_string) - 1);
break;
case EMAIL_SORT_ORDER_NOCASE_DESCEND:
- EM_SAFE_STRCAT(result_rule_string, " COLLATE NOCASE DESC ");
+ EM_SAFE_STRNCAT(result_rule_string, " COLLATE NOCASE DESC ", QUERY_SIZE - EM_SAFE_STRLEN(result_rule_string) - 1);
break;
case EMAIL_SORT_ORDER_TO_CCBCC: