Skip to content

Commit

Permalink
permissions: store src ip in zero terminated string for trusted table
Browse files Browse the repository at this point in the history
- it is printed as string via rpc, resulting in invalid chars in the
  output
- reported by Emmanuel Schmidbauer, GH#137

(cherry picked from commit 89642d3)
  • Loading branch information
miconda committed May 12, 2015
1 parent e2f304f commit 574c8ba
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion modules/permissions/hash.c
Expand Up @@ -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");
Expand All @@ -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);
Expand Down

0 comments on commit 574c8ba

Please sign in to comment.