Skip to content

Commit

Permalink
auth_xkeys: clone value before inserting the lump inside auth_xkeys_a…
Browse files Browse the repository at this point in the history
…dd()

(cherry picked from commit 01f5ecb)
(cherry picked from commit 3a2d992)
(cherry picked from commit 3e6f951)
  • Loading branch information
miconda committed Apr 3, 2019
1 parent 85edb21 commit 68cb301
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/modules/auth_xkeys/auth_xkeys.c
Expand Up @@ -202,6 +202,7 @@ int auth_xkeys_add(sip_msg_t* msg, str *hdr, str *key,
auth_xkey_t *itc;
char xout[SHA512_DIGEST_STRING_LENGTH];
struct lump* anchor;
char *p;

if(_auth_xkeys_list==NULL || *_auth_xkeys_list==NULL) {
LM_ERR("no stored keys\n");
Expand Down Expand Up @@ -266,8 +267,16 @@ int auth_xkeys_add(sip_msg_t* msg, str *hdr, str *key,
LM_ERR("can't get anchor\n");
return -1;
}
if (insert_new_lump_before(anchor, xdata.s, xdata.len, 0) == 0) {
p = (char*)pkg_malloc(xdata.len+1);
if(p==NULL) {
LM_ERR("no more pkg memory\n");
return -2;
}
memcpy(p, xdata.s, xdata.len);
p[xdata.len] = '\0';
if (insert_new_lump_before(anchor, p, xdata.len, 0) == 0) {
LM_ERR("cannot insert the new header [%.*s]\n", hdr->len, hdr->s);
pkg_free(p);
return -1;
}
return 0;
Expand Down

0 comments on commit 68cb301

Please sign in to comment.