From 2b5319b37ca90871821e845ead64b67a59780522 Mon Sep 17 00:00:00 2001 From: Runji Wang Date: Sun, 30 May 2021 18:48:36 +0800 Subject: [PATCH] IOR: fix overflow in offset calculations In expression 'i * test->numTasks', both operands have int type. It will overflow 32 bits when the 'segmentCount' and 'numTasks' are large enough. --- src/ior.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ior.c b/src/ior.c index cf96cd8..65f7a2f 100755 --- a/src/ior.c +++ b/src/ior.c @@ -1679,7 +1679,7 @@ static void prefillSegment(IOR_param_t *test, void * randomPrefillBuffer, int pr IOR_offset_t transferCount; int errors; ioBuffers->buffer = randomPrefillBuffer; - for (int i = startSegment; i < endSegment; i++){ + for (IOR_offset_t i = startSegment; i < endSegment; i++){ for (int j = 0; j < offsets; j++) { IOR_offset_t offset = j * test->randomPrefillBlocksize; if (test->filePerProc) { @@ -1707,7 +1707,7 @@ static IOR_offset_t WriteOrRead(IOR_param_t *test, IOR_results_t *results, IOR_offset_t dataMoved = 0; /* for data rate calculation */ double startForStonewall; int hitStonewall; - int i, j; + IOR_offset_t i, j; IOR_point_t *point = ((access == WRITE) || (access == WRITECHECK)) ? &results->write : &results->read;