Skip to content

Commit

Permalink
lib/srdb1: detect if ipv6 address is between square brakets
Browse files Browse the repository at this point in the history
- if not, let it be host part with surrounding brakets, because it can
by a mysql conf group name
  • Loading branch information
miconda committed Oct 25, 2019
1 parent 4bb8bc9 commit 2aa614d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/lib/srdb1/db_id.c
Expand Up @@ -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>
Expand Down Expand Up @@ -111,6 +112,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;
Expand Down Expand Up @@ -253,7 +255,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;
}
Expand Down

0 comments on commit 2aa614d

Please sign in to comment.