From 5c67b2c99de39c988be7c5fffd504fdbaae74a01 Mon Sep 17 00:00:00 2001 From: Kaushal M Date: Wed, 11 Apr 2012 13:40:28 +0530 Subject: glusterd: IPv4 auth improvment Check if last character of an IPv4 address is valid to prevent successful validation of addresses with '.' as last character. Change-Id: I0af6c288e12a47986ce3f8b02c317b99767e69e6 BUG: 811458 Signed-off-by: Kaushal M Reviewed-on: http://review.gluster.com/3124 Tested-by: Gluster Build System Reviewed-by: Jeff Darcy Reviewed-by: Vijay Bellur --- libglusterfs/src/common-utils.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'libglusterfs/src/common-utils.c') diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index c5080246a..c19004912 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -1660,6 +1660,13 @@ valid_ipv4_address (char *address, int length, gf_boolean_t wildcard_acc) int is_wildcard = 0; tmp = gf_strdup (address); + + /* To prevent cases where last character is '.' */ + if (!isdigit (tmp[length - 1]) && (tmp[length - 1] != '*')) { + ret = 0; + goto out; + } + prev = tmp; prev = strtok_r (tmp, ".", &ptr); -- cgit