summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/common-utils.c
diff options
context:
space:
mode:
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;
}