From 7a07683edc904334294b0853f871f20fed65cbef Mon Sep 17 00:00:00 2001 From: Guy Margalit Date: Wed, 20 Apr 2022 02:27:58 +0300 Subject: [PATCH] Fix #425 - gap int overflow with size over 2 GB and hashCheck=true --- .../intel/cosbench/driver/generator/RandomInputStream.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/cosbench-driver/src/com/intel/cosbench/driver/generator/RandomInputStream.java b/dev/cosbench-driver/src/com/intel/cosbench/driver/generator/RandomInputStream.java index 0ff4193f..a75a8c9f 100644 --- a/dev/cosbench-driver/src/com/intel/cosbench/driver/generator/RandomInputStream.java +++ b/dev/cosbench-driver/src/com/intel/cosbench/driver/generator/RandomInputStream.java @@ -96,7 +96,7 @@ protected void processBytes(byte[] bytes, int offset, int length) { return; } - int gap = (int) ((processed + length) - (size - hashLen)); + long gap = (processed + length) - (size - hashLen); if (gap > 0) // partial hash needs append in gap area. length -= gap; @@ -122,7 +122,7 @@ protected void processBytes(byte[] bytes, int offset, int length) { } if (gap > 0) - System.arraycopy(hashBytes, 0, bytes, offset, gap); + System.arraycopy(hashBytes, 0, bytes, offset, (int) gap); } }