summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/common-utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'libglusterfs/src/common-utils.c')
-rw-r--r--libglusterfs/src/common-utils.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c
index 82a493669ac..671a3e549dc 100644
--- a/libglusterfs/src/common-utils.c
+++ b/libglusterfs/src/common-utils.c
@@ -1703,7 +1703,8 @@ valid_ipv4_address (char *address, int length, gf_boolean_t wildcard_acc)
tmp = gf_strdup (address);
/* To prevent cases where last character is '.' */
- if (!isdigit (tmp[length - 1]) && (tmp[length - 1] != '*')) {
+ if (length <= 0 ||
+ (!isdigit (tmp[length - 1]) && (tmp[length - 1] != '*'))) {
ret = 0;
goto out;
}
@@ -1749,7 +1750,7 @@ valid_ipv6_address (char *address, int length, gf_boolean_t wildcard_acc)
tmp = gf_strdup (address);
/* Check for compressed form */
- if (tmp[length - 1] == ':') {
+ if (length <= 0 || tmp[length - 1] == ':') {
ret = 0;
goto out;
}