summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authorKaushal M <kaushal@redhat.com>2012-04-16 12:07:15 +0530
committerVijay Bellur <vijay@gluster.com>2012-04-18 23:18:48 -0700
commitc9a8da5bb8c78aba4b2477c011e2a4f335351fd8 (patch)
treec1d1c37c0b59d7de644d6da20ca1f66a8c074fa9 /libglusterfs
parent6ff8c16cbaa23e209d270d2d559a6072e554e68f (diff)
glusterd: Properly validate compressed form of IPv6 addresses
Properly validate IPv6 compressed notation, when used in volume set. Change-Id: Ia489125a45472fc0971c6b11de073aaeb9b1a123 BUG: 810442 Signed-off-by: Kaushal M <kaushal@redhat.com> Reviewed-on: http://review.gluster.com/3152 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vijay@gluster.com>
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/common-utils.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c
index c190049122c..cc73a8b7abb 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;
}