Module: kamailio Branch: 4.2 Commit: f28c1afd0815d3f31b1ce19c3252a14f11da27fb URL: https://github.com/kamailio/kamailio/commit/f28c1afd0815d3f31b1ce19c3252a14f...
Author: Juha Heinanen jh@tutpro.com Committer: Juha Heinanen jh@tutpro.com Date: 2015-01-31T04:21:34+02:00
db_mysql: restore group ending character in db url
- manual cherry-pick from master (git git cherry-pick -x 1d3b89b10bfd825e4ca73bb95b0ae489843dd9f1 failed)
---
Modified: modules/db_mysql/km_my_con.c
---
Diff: https://github.com/kamailio/kamailio/commit/f28c1afd0815d3f31b1ce19c3252a14f... Patch: https://github.com/kamailio/kamailio/commit/f28c1afd0815d3f31b1ce19c3252a14f...
---
diff --git a/modules/db_mysql/km_my_con.c b/modules/db_mysql/km_my_con.c index 4d29c6c..bfd81e9 100644 --- a/modules/db_mysql/km_my_con.c +++ b/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* ptr; - char *host, *grp; + char *host, *grp, *egrp;
if (!id) { LM_ERR("invalid parameter value\n"); @@ -56,6 +56,7 @@ struct my_con* db_mysql_new_connection(const struct db_id* id) return 0; }
+ egrp = 0; memset(ptr, 0, sizeof(struct my_con)); ptr->ref = 1; @@ -67,9 +68,10 @@ struct my_con* db_mysql_new_connection(const struct db_id* id)
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; - *host = '\0'; + *egrp = '\0'; + host = egrp; if (host != id->host + strlen(id->host)-1) { 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->id = (struct db_id*)id; + if(egrp) *egrp = ']'; return ptr;
err: if (ptr && ptr->con) pkg_free(ptr->con); if (ptr) pkg_free(ptr); + if(egrp) *egrp = ']'; return 0; }