From 845aba3ddcfaf7bcef283002b7b5bbf2075d4539 Mon Sep 17 00:00:00 2001 From: Krutika Dhananjay Date: Fri, 23 Nov 2012 10:33:12 +0530 Subject: glusterd: fail vol set when value = empty string/string with all whitespaces PROBLEM: 'volume set' operation accepts empty strings and strings containing all whitespaces for value. The result - subsequent attempts to start glusterd fail. FIX: Added relevant checks in xlator_option_validate_* functions in options.c and in conversion functions in common-utils.c to invalidate wrong option values. Change-Id: I33232c6b42ab4fcce85c2d0e0b0da145fc9232c3 BUG: 859927 Signed-off-by: Krutika Dhananjay Reviewed-on: http://review.gluster.org/4033 Reviewed-by: Pranith Kumar Karampuri Tested-by: Gluster Build System Reviewed-by: Anand Avati --- libglusterfs/src/common-utils.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'libglusterfs/src/common-utils.c') diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index 40a687953..c327d4fe4 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -666,6 +666,8 @@ gf_string2time (const char *str, uint32_t *n) old_errno = errno; errno = 0; value = strtol (str, &tail, 0); + if (str == tail) + errno = EINVAL; if (errno == ERANGE || errno == EINVAL) return -1; @@ -709,6 +711,8 @@ gf_string2percent (const char *str, double *n) old_errno = errno; errno = 0; value = strtod (str, &tail); + if (str == tail) + errno = EINVAL; if (errno == ERANGE || errno == EINVAL) return -1; @@ -742,6 +746,8 @@ _gf_string2long (const char *str, long *n, int base) old_errno = errno; errno = 0; value = strtol (str, &tail, base); + if (str == tail) + errno = EINVAL; if (errno == ERANGE || errno == EINVAL) return -1; @@ -782,6 +788,8 @@ _gf_string2ulong (const char *str, unsigned long *n, int base) old_errno = errno; errno = 0; value = strtoul (str, &tail, base); + if (str == tail) + errno = EINVAL; if (errno == ERANGE || errno == EINVAL) return -1; @@ -822,6 +830,8 @@ _gf_string2uint (const char *str, unsigned int *n, int base) old_errno = errno; errno = 0; value = strtoul (str, &tail, base); + if (str == tail) + errno = EINVAL; if (errno == ERANGE || errno == EINVAL) return -1; @@ -853,6 +863,8 @@ _gf_string2double (const char *str, double *n) old_errno = errno; errno = 0; value = strtod (str, &tail); + if (str == tail) + errno = EINVAL; if (errno == ERANGE || errno == EINVAL) return -1; @@ -884,6 +896,8 @@ _gf_string2longlong (const char *str, long long *n, int base) old_errno = errno; errno = 0; value = strtoll (str, &tail, base); + if (str == tail) + errno = EINVAL; if (errno == ERANGE || errno == EINVAL) return -1; @@ -924,6 +938,8 @@ _gf_string2ulonglong (const char *str, unsigned long long *n, int base) old_errno = errno; errno = 0; value = strtoull (str, &tail, base); + if (str == tail) + errno = EINVAL; if (errno == ERANGE || errno == EINVAL) return -1; @@ -1288,6 +1304,8 @@ gf_string2bytesize (const char *str, uint64_t *n) old_errno = errno; errno = 0; value = strtod (str, &tail); + if (str == tail) + errno = EINVAL; if (errno == ERANGE || errno == EINVAL) return -1; @@ -1344,6 +1362,8 @@ gf_string2percent_or_bytesize (const char *str, old_errno = errno; errno = 0; value = strtoull (str, &tail, 10); + if (str == tail) + errno = EINVAL; if (errno == ERANGE || errno == EINVAL) return -1; -- cgit