Module: kamailio
Branch: master
Commit: 89642d3cddd90ba3e3f6d310e239492634fa6405
URL:
https://github.com/kamailio/kamailio/commit/89642d3cddd90ba3e3f6d310e239492…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2015-04-23T16:24:39+02:00
permissions: store src ip in zero terminated string for trusted table
- it is printed as string via rpc, resulting in invalid chars in the
output
- reported by Emmanuel Schmidbauer, GH#137
---
Modified: modules/permissions/hash.c
---
Diff:
https://github.com/kamailio/kamailio/commit/89642d3cddd90ba3e3f6d310e239492…
Patch:
https://github.com/kamailio/kamailio/commit/89642d3cddd90ba3e3f6d310e239492…
---
diff --git a/modules/permissions/hash.c b/modules/permissions/hash.c
index 200e2c1..7b11ebd 100644
--- a/modules/permissions/hash.c
+++ b/modules/permissions/hash.c
@@ -155,7 +155,7 @@ int hash_table_insert(struct trusted_list** table, char* src_ip,
}
np->src_ip.len = strlen(src_ip);
- np->src_ip.s = (char *) shm_malloc(np->src_ip.len);
+ np->src_ip.s = (char *) shm_malloc(np->src_ip.len+1);
if (np->src_ip.s == NULL) {
LM_CRIT("cannot allocate shm memory for src_ip string\n");
@@ -164,6 +164,7 @@ int hash_table_insert(struct trusted_list** table, char* src_ip,
}
(void) strncpy(np->src_ip.s, src_ip, np->src_ip.len);
+ np->src_ip.s[np->src_ip.len] = 0;
if (pattern) {
np->pattern = (char *) shm_malloc(strlen(pattern)+1);