Skip to content

Commit

Permalink
rest_client: Fix a string handling bug in append_hf()
Browse files Browse the repository at this point in the history
Issue reported by Pasan Meemaduma
  • Loading branch information
liviuchircu committed Feb 15, 2018
1 parent 2254d00 commit 888d5e9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion modules/rest_client/rest_methods.c
Expand Up @@ -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;
}
Expand All @@ -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;
Expand Down

0 comments on commit 888d5e9

Please sign in to comment.