summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaushal M <kaushal@redhat.com>2013-10-10 17:20:57 +0530
committerAnand Avati <avati@redhat.com>2013-10-14 15:00:25 -0700
commit793f8491789e58791b090a74472959df117e404b (patch)
tree127ed665afda0132c766efb2cd74a29948979730
parent75caba63714c7f7f9ab810937dae69a1a28ece53 (diff)
libglusterfs: Account for overflow in gf_string2bytesize
gf_string2bytesize will now return an error when a value is greater than UINT64_MAX and set errno to EOVERFLOW. This is needed because casting a double value greater than UINT64_MAX to uint64_t will convert it to 0. BUG: 1017746 Change-Id: I6f96efc1e3a1c236685593a6fb7f806a87e46019 Signed-off-by: Kaushal M <kaushal@redhat.com> Reviewed-on: http://review.gluster.org/6068 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
-rw-r--r--libglusterfs/src/common-utils.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c
index d57cd8a55fe..c37a876dfc6 100644
--- a/libglusterfs/src/common-utils.c
+++ b/libglusterfs/src/common-utils.c
@@ -1500,6 +1500,12 @@ gf_string2percent_or_bytesize (const char *str,
return -1;
}
+ /* Error out if we cannot store the value in uint64 */
+ if (value > UINT64_MAX) {
+ errno = EOVERFLOW;
+ return -1;
+ }
+
*n = (uint64_t) value;
return 0;