Module: kamailio
Branch: 5.2
Commit: 4437787b3de382ffa8a7df0fad54f5226c1bafd5
URL:
https://github.com/kamailio/kamailio/commit/4437787b3de382ffa8a7df0fad54f52…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Henning Westerholt <hw(a)skalatan.de>
Date: 2019-10-29T14:53:09+01:00
lib/srdb1: detect if ipv6 address is between square brakets
- if not, let it be host part with surrounding brakets, because it can
by a mysql conf group name
(cherry picked from commit 2aa614d49f4917faec62534a51fcf8ddfc5fb870)
---
Modified: src/lib/srdb1/db_id.c
---
Diff:
https://github.com/kamailio/kamailio/commit/4437787b3de382ffa8a7df0fad54f52…
Patch:
https://github.com/kamailio/kamailio/commit/4437787b3de382ffa8a7df0fad54f52…
---
diff --git a/src/lib/srdb1/db_id.c b/src/lib/srdb1/db_id.c
index 8a43def2d9..b0166cccfd 100644
--- a/src/lib/srdb1/db_id.c
+++ b/src/lib/srdb1/db_id.c
@@ -29,6 +29,7 @@
#include "db_id.h"
#include "../../core/dprint.h"
#include "../../core/mem/mem.h"
+#include "../../core/resolve.h"
#include "../../core/pt.h"
#include "../../core/ut.h"
#include <stdlib.h>
@@ -109,6 +110,7 @@ static int parse_db_url(struct db_id* id, const str* url)
unsigned int len, i, j, a, foundanother, ipv6_flag=0;
const char* begin;
char* prev_token;
+ str sval = STR_NULL;
foundanother = 0;
prev_token = 0;
@@ -251,7 +253,14 @@ static int parse_db_url(struct db_id* id, const str* url)
case ST_HOST6:
switch(url->s[i]) {
case ']':
- ipv6_flag = 1;
+ sval.s = (char*)begin;
+ sval.len = url->s + i - begin;
+ if(str2ip6(&sval)==NULL) {
+ ipv6_flag = 0;
+ begin -= 1;
+ } else {
+ ipv6_flag = 1;
+ }
st = ST_HOST;
break;
}