Module: kamailio
Branch: 5.1
Commit: 0f177325c54c7c06142907b8351f7293c7e43087
URL:
https://github.com/kamailio/kamailio/commit/0f177325c54c7c06142907b8351f729…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Henning Westerholt <hw(a)skalatan.de>
Date: 2019-10-29T14:53:33+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/0f177325c54c7c06142907b8351f729…
Patch:
https://github.com/kamailio/kamailio/commit/0f177325c54c7c06142907b8351f729…
---
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;
}