Module: kamailio
Branch: master
Commit: 01f5ecbc45c236daea62d6638a02c168720c8479
URL:
https://github.com/kamailio/kamailio/commit/01f5ecbc45c236daea62d6638a02c16…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2018-12-04T11:17:35+01:00
auth_xkeys: clone value before inserting the lump inside auth_xkeys_add()
---
Modified: src/modules/auth_xkeys/auth_xkeys.c
---
Diff:
https://github.com/kamailio/kamailio/commit/01f5ecbc45c236daea62d6638a02c16…
Patch:
https://github.com/kamailio/kamailio/commit/01f5ecbc45c236daea62d6638a02c16…
---
diff --git a/src/modules/auth_xkeys/auth_xkeys.c b/src/modules/auth_xkeys/auth_xkeys.c
index 980260988e..53b7325dff 100644
--- a/src/modules/auth_xkeys/auth_xkeys.c
+++ b/src/modules/auth_xkeys/auth_xkeys.c
@@ -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");
@@ -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;