diff --git a/modules/rest_client/rest_methods.c b/modules/rest_client/rest_methods.c index 09827ba93a3..56fa154db77 100644 --- a/modules/rest_client/rest_methods.c +++ b/modules/rest_client/rest_methods.c @@ -1072,7 +1072,7 @@ int rest_append_hf_method(struct sip_msg *msg, str *hfv) { char buf[MAX_HEADER_FIELD_LEN]; - if (hfv->len > MAX_HEADER_FIELD_LEN) { + if (hfv->len + 1 > MAX_HEADER_FIELD_LEN) { LM_ERR("header field buffer too small\n"); return -1; } @@ -1081,6 +1081,7 @@ int rest_append_hf_method(struct sip_msg *msg, str *hfv) /* append the header to the global list */ strncpy(buf, hfv->s, hfv->len); + buf[hfv->len] = '\0'; header_list = curl_slist_append(header_list, buf); return 1;