From 05d8c37c1e1b0554985196d507df3a65c764873b Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Wed, 16 Oct 2013 21:24:32 -0700 Subject: 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 Reviewed-on: http://review.gluster.org/6101 Reviewed-by: Kaushal M Tested-by: Gluster Build System Reviewed-by: Anand Avati --- libglusterfs/src/common-utils.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index c37a876df..eafa72dea 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; } -- cgit