summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/common-utils.c
diff options
context:
space:
mode:
authorKrutika Dhananjay <kdhananj@redhat.com>2012-11-23 10:33:12 +0530
committerAnand Avati <avati@redhat.com>2012-12-10 14:18:17 -0800
commit845aba3ddcfaf7bcef283002b7b5bbf2075d4539 (patch)
treedf3c803ed422683ce7b2b75a0a8f52d542003329 /libglusterfs/src/common-utils.c
parent07c40a2d149f9adfa4ce400051c1313127349192 (diff)
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 <kdhananj@redhat.com> Reviewed-on: http://review.gluster.org/4033 Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'libglusterfs/src/common-utils.c')
-rw-r--r--libglusterfs/src/common-utils.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c
index 40a68795302..c327d4fe43c 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;