summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2012-06-20 13:45:46 +0200
committerAnand Avati <avati@redhat.com>2012-07-02 15:45:29 -0700
commit295c0280d117cfca85f354d8098ea72c30ef2ced (patch)
treefbf9c2e0a8fd37861eda9a3edc55c92e8dccf177 /libglusterfs
parentc62eeda7718e4c15e19ade68455826ab32438f98 (diff)
valid_ipv4_address: don't access addr[-1] for 0-length input string
valid_ipv6_address: Likewise. Change-Id: I6225873a5e323f81de5f25335aceeee571629e28 BUG: 789278 Signed-off-by: Jim Meyering <meyering@redhat.com> Reviewed-on: http://review.gluster.com/3602 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'libglusterfs')
-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;
}