diff options
Diffstat (limited to 'libglusterfs/src')
-rw-r--r-- | libglusterfs/src/common-utils.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index c19004912..cc73a8b7a 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -1699,11 +1699,30 @@ valid_ipv6_address (char *address, int length, gf_boolean_t wildcard_acc) { int hex_numbers = 0; int value = 0; + int i = 0; char *tmp = NULL, *ptr = NULL, *prev = NULL, *endptr = NULL; char ret = 1; int is_wildcard = 0; + int is_compressed = 0; tmp = gf_strdup (address); + + /* Check for compressed form */ + if (tmp[length - 1] == ':') { + ret = 0; + goto out; + } + for (i = 0; i < (length - 1) ; i++) { + if (tmp[i] == ':' && tmp[i + 1] == ':') { + if (is_compressed == 0) + is_compressed = 1; + else { + ret = 0; + goto out; + } + } + } + prev = strtok_r (tmp, ":", &ptr); while (prev != NULL) { @@ -1721,7 +1740,8 @@ valid_ipv6_address (char *address, int length, gf_boolean_t wildcard_acc) prev = strtok_r (NULL, ":", &ptr); } - if ((hex_numbers > 8) || (hex_numbers < 8 && !is_wildcard)) { + if ((hex_numbers > 8) || (hex_numbers < 8 && !is_wildcard + && !is_compressed)) { ret = 0; } |