Skip to content

Commit

Permalink
redis: fix crash when using FQDN in URL
Browse files Browse the repository at this point in the history
(cherry picked from commit 4cf5a16)
  • Loading branch information
razvancrainea committed Sep 11, 2014
1 parent 4c08b62 commit c0029e8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion modules/cachedb_redis/cachedb_redis_dbase.h
Expand Up @@ -30,7 +30,7 @@
#include "../../cachedb/cachedb.h"

typedef struct cluster_nodes {
char ip[16]; /* ip of this cluster node */
char *ip; /* ip of this cluster node */
short port; /* port of this cluster node */
unsigned short start_slot; /* first slot for this server */
unsigned short end_slot; /* last slot for this server */
Expand Down
7 changes: 5 additions & 2 deletions modules/cachedb_redis/cachedb_redis_utils.c
Expand Up @@ -187,6 +187,7 @@ int build_cluster_nodes(redis_con *con,char *info,int size)
int masters = 1, count = 0;
char *ip, *block = NULL;
unsigned short port,start_slot,end_slot;
int len;

// Define **pointers for new structures
struct datavalues **newret1 = pkg_malloc(sizeof(struct datavalues *));
Expand Down Expand Up @@ -269,14 +270,16 @@ int build_cluster_nodes(redis_con *con,char *info,int size)

if ( ip == NULL || !(port > 0) || (start_slot > end_slot) || !(end_slot > 0) ) {block = ":processing row"; goto error;}

new = pkg_malloc(sizeof(cluster_node));
len = strlen(ip);
new = pkg_malloc(sizeof(cluster_node) + len + 1);
if (!new) {
LM_ERR("no more pkg\n");
goto error;
}

memset(new,0,sizeof(cluster_node));
memset(new,0,sizeof(cluster_node) + len + 1);

new->ip = (char *)(new + 1);
strcpy(new->ip,ip);
new->port = port;
new->start_slot = start_slot;
Expand Down

0 comments on commit c0029e8

Please sign in to comment.