Browse Source

db_mysql: restore group ending character in db url

- manual cherry-pick from master (git git cherry-pick -x
  1d3b89b10bfd825e4ca73bb95b0ae489843dd9f1 failed)
Juha Heinanen 10 years ago
parent
commit
f28c1afd08
1 changed files with 7 additions and 3 deletions
  1. 7 3
      modules/db_mysql/km_my_con.c

+ 7 - 3
modules/db_mysql/km_my_con.c

@@ -43,7 +43,7 @@
 struct my_con* db_mysql_new_connection(const struct db_id* id)
 struct my_con* db_mysql_new_connection(const struct db_id* id)
 {
 {
 	struct my_con* ptr;
 	struct my_con* ptr;
-	char *host, *grp;
+	char *host, *grp, *egrp;
 
 
 	if (!id) {
 	if (!id) {
 		LM_ERR("invalid parameter value\n");
 		LM_ERR("invalid parameter value\n");
@@ -56,6 +56,7 @@ struct my_con* db_mysql_new_connection(const struct db_id* id)
 		return 0;
 		return 0;
 	}
 	}
 
 
+	egrp = 0;
 	memset(ptr, 0, sizeof(struct my_con));
 	memset(ptr, 0, sizeof(struct my_con));
 	ptr->ref = 1;
 	ptr->ref = 1;
 	
 	
@@ -67,9 +68,10 @@ struct my_con* db_mysql_new_connection(const struct db_id* id)
 
 
 	mysql_init(ptr->con);
 	mysql_init(ptr->con);
 
 
-	if (id->host[0] == '[' && (host = strchr(id->host, ']')) != NULL) {
+	if (id->host[0] == '[' && (egrp = strchr(id->host, ']')) != NULL) {
 		grp = id->host + 1;
 		grp = id->host + 1;
-		*host = '\0';
+		*egrp = '\0';
+		host = egrp;
 		if (host != id->host + strlen(id->host)-1) {
 		if (host != id->host + strlen(id->host)-1) {
 			host += 1; // host found after closing bracket
 			host += 1; // host found after closing bracket
 		}
 		}
@@ -124,11 +126,13 @@ struct my_con* db_mysql_new_connection(const struct db_id* id)
 
 
 	ptr->timestamp = time(0);
 	ptr->timestamp = time(0);
 	ptr->id = (struct db_id*)id;
 	ptr->id = (struct db_id*)id;
+	if(egrp) *egrp = ']';
 	return ptr;
 	return ptr;
 
 
  err:
  err:
 	if (ptr && ptr->con) pkg_free(ptr->con);
 	if (ptr && ptr->con) pkg_free(ptr->con);
 	if (ptr) pkg_free(ptr);
 	if (ptr) pkg_free(ptr);
+	if(egrp) *egrp = ']';
 	return 0;
 	return 0;
 }
 }