gcc: remove format-truncation compilation warnings

This commit is contained in:
Kaian 2021-10-25 16:28:47 +02:00
parent c196bac61c
commit 4f1db81e27
3 changed files with 9 additions and 9 deletions

View File

@ -465,12 +465,12 @@ call_flow_draw_message(ui_t *ui, call_flow_arrow_t *arrow, int cline)
timeval_to_time(msg_get_time(msg), msg_time); timeval_to_time(msg_get_time(msg), msg_time);
// Get Message method (include extra info) // Get Message method (include extra info)
snprintf(method, METHOD_MAXLEN, "%s", msg_method); snprintf(method, METHOD_MAXLEN, "%.*s", METHOD_MAXLEN-1, msg_method);
// If message has sdp information // If message has sdp information
if (msg_has_sdp(msg) && setting_has_value(SETTING_CF_SDP_INFO, "off")) { if (msg_has_sdp(msg) && setting_has_value(SETTING_CF_SDP_INFO, "off")) {
// Show sdp tag in title // Show sdp tag in title
snprintf(method, METHOD_MAXLEN, "%s (SDP)", msg_method ); snprintf(method, METHOD_MAXLEN, "%.*s (SDP)", METHOD_MAXLEN-7, msg_method );
} }
// If message has sdp information // If message has sdp information

View File

@ -444,7 +444,7 @@ filter_field_method(int field_id)
void void
filter_method_from_setting(const char *value) filter_method_from_setting(const char *value)
{ {
char methods[256], method_expr[256]; char methods[250], method_expr[256];
int methods_len = strlen(value); int methods_len = strlen(value);
char *comma; char *comma;
@ -459,7 +459,7 @@ filter_method_from_setting(const char *value)
// Create a regular expression // Create a regular expression
memset(method_expr, 0, sizeof(method_expr)); memset(method_expr, 0, sizeof(method_expr));
sprintf(method_expr, "(%s)", methods); snprintf(method_expr, sizeof(method_expr), "(%s)", methods);
filter_set(FILTER_METHOD, method_expr); filter_set(FILTER_METHOD, method_expr);
} else { } else {
filter_set(FILTER_METHOD, " "); filter_set(FILTER_METHOD, " ");

View File

@ -543,7 +543,7 @@ sip_get_msg_reqresp(sip_msg_t *msg, const u_char *payload)
// Method & CSeq // Method & CSeq
if (regexec(&calls.reg_method, (const char *)payload, 2, pmatch, 0) == 0) { if (regexec(&calls.reg_method, (const char *)payload, 2, pmatch, 0) == 0) {
if ((int)(pmatch[1].rm_eo - pmatch[1].rm_so) >= SIP_ATTR_MAXLEN) { if ((int)(pmatch[1].rm_eo - pmatch[1].rm_so) >= SIP_ATTR_MAXLEN) {
strncpy(reqresp, "<malformed>", 11); strncpy(reqresp, "<malformed>", 12);
} else { } else {
sprintf(reqresp, "%.*s", (int) (pmatch[1].rm_eo - pmatch[1].rm_so), payload + pmatch[1].rm_so); sprintf(reqresp, "%.*s", (int) (pmatch[1].rm_eo - pmatch[1].rm_so), payload + pmatch[1].rm_so);
} }
@ -559,12 +559,12 @@ sip_get_msg_reqresp(sip_msg_t *msg, const u_char *payload)
// Response code // Response code
if (regexec(&calls.reg_response, (const char *)payload, 3, pmatch, 0) == 0) { if (regexec(&calls.reg_response, (const char *)payload, 3, pmatch, 0) == 0) {
if ((int)(pmatch[1].rm_eo - pmatch[1].rm_so) >= SIP_ATTR_MAXLEN) { if ((int)(pmatch[1].rm_eo - pmatch[1].rm_so) >= SIP_ATTR_MAXLEN) {
strncpy(resp_str, "<malformed>", 11); strncpy(resp_str, "<malformed>", 12);
} else { } else {
sprintf(resp_str, "%.*s", (int) (pmatch[1].rm_eo - pmatch[1].rm_so), payload + pmatch[1].rm_so); sprintf(resp_str, "%.*s", (int) (pmatch[1].rm_eo - pmatch[1].rm_so), payload + pmatch[1].rm_so);
} }
if ((int)(pmatch[2].rm_eo - pmatch[2].rm_so) >= SIP_ATTR_MAXLEN) { if ((int)(pmatch[2].rm_eo - pmatch[2].rm_so) >= SIP_ATTR_MAXLEN) {
strncpy(resp_str, "<malformed>", 11); strncpy(resp_str, "<malformed>", 12);
} else { } else {
sprintf(reqresp, "%.*s", (int) (pmatch[2].rm_eo - pmatch[2].rm_so), payload + pmatch[2].rm_so); sprintf(reqresp, "%.*s", (int) (pmatch[2].rm_eo - pmatch[2].rm_so), payload + pmatch[2].rm_so);
} }
@ -617,7 +617,7 @@ sip_parse_msg_payload(sip_msg_t *msg, const u_char *payload)
} else { } else {
// Malformed From Header // Malformed From Header
msg->sip_from = sng_malloc(12); msg->sip_from = sng_malloc(12);
strncpy(msg->sip_from, "<malformed>", 11); strncpy(msg->sip_from, "<malformed>", 12);
} }
// To // To
@ -627,7 +627,7 @@ sip_parse_msg_payload(sip_msg_t *msg, const u_char *payload)
} else { } else {
// Malformed To Header // Malformed To Header
msg->sip_to = sng_malloc(12); msg->sip_to = sng_malloc(12);
strncpy(msg->sip_to, "<malformed>", 11); strncpy(msg->sip_to, "<malformed>", 12);
} }
return 0; return 0;