summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/common-utils.c
diff options
context:
space:
mode:
authorHarshavardhana <harsha@harshavardhana.net>2013-10-16 21:24:32 -0700
committerAnand Avati <avati@redhat.com>2013-10-17 17:05:18 -0700
commit05d8c37c1e1b0554985196d507df3a65c764873b (patch)
tree0139c57d72df2b75425d49ea01dc5e4381e10399 /libglusterfs/src/common-utils.c
parent9a31a25cfa3d8a4355412e2fff93482bb7352a52 (diff)
libglusterfs: Return 'ERANGE' for ASCII string to number system
Using 'EOVERFLOW' should be limited to data structure alignments not Number systems. Change-Id: I7d337d414e998c0a729c95661df239e36c753a38 BUG: 1017746 Signed-off-by: Harshavardhana <harsha@harshavardhana.net> Reviewed-on: http://review.gluster.org/6101 Reviewed-by: Kaushal M <kaushal@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.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c
index c37a876dfc6..eafa72dea95 100644
--- a/libglusterfs/src/common-utils.c
+++ b/libglusterfs/src/common-utils.c
@@ -1441,6 +1441,11 @@ gf_string2bytesize (const char *str, uint64_t *n)
return -1;
}
+ if ((UINT64_MAX - value) < 0) {
+ errno = ERANGE;
+ return -1;
+ }
+
*n = (uint64_t) value;
return 0;
@@ -1501,8 +1506,8 @@ gf_string2percent_or_bytesize (const char *str,
}
/* Error out if we cannot store the value in uint64 */
- if (value > UINT64_MAX) {
- errno = EOVERFLOW;
+ if ((UINT64_MAX - value) < 0) {
+ errno = ERANGE;
return -1;
}