Fix for sanitizer finds

pull/6868/head
Lealem Amedie 2023-11-17 13:28:30 -07:00
parent 2c7248492f
commit 07d6d75d72
1 changed files with 23 additions and 8 deletions

View File

@ -2676,6 +2676,7 @@ static void* benchmarks_do(void* args)
#ifndef NO_FILESYSTEM #ifndef NO_FILESYSTEM
if (hash_input) { if (hash_input) {
int rawSz;
XFILE file; XFILE file;
file = XFOPEN(hash_input, "rb"); file = XFOPEN(hash_input, "rb");
if (file == XBADFILE) if (file == XBADFILE)
@ -2694,14 +2695,20 @@ static void* benchmarks_do(void* args)
XFREE(bench_plain, HEAP_HINT, DYNAMIC_TYPE_WOLF_BIGINT); XFREE(bench_plain, HEAP_HINT, DYNAMIC_TYPE_WOLF_BIGINT);
bench_plain = (byte*)XMALLOC((size_t)bench_buf_size, rawSz = bench_buf_size;
if (bench_buf_size % 16)
bench_buf_size += 16 - (bench_buf_size % 16);
bench_size = bench_buf_size;
bench_plain = (byte*)XMALLOC((size_t)bench_buf_size + 16*2,
HEAP_HINT, DYNAMIC_TYPE_WOLF_BIGINT); HEAP_HINT, DYNAMIC_TYPE_WOLF_BIGINT);
if (bench_plain == NULL) if (bench_plain == NULL)
goto exit; goto exit;
if ((size_t)XFREAD(bench_plain, 1, bench_buf_size, file) if ((size_t)XFREAD(bench_plain, 1, rawSz, file)
!= (size_t)bench_buf_size) { != (size_t)rawSz) {
XFCLOSE(file); XFCLOSE(file);
goto exit; goto exit;
} }
@ -2711,6 +2718,7 @@ static void* benchmarks_do(void* args)
} }
if (cipher_input) { if (cipher_input) {
int rawSz;
XFILE file; XFILE file;
file = XFOPEN(cipher_input, "rb"); file = XFOPEN(cipher_input, "rb");
if (file == XBADFILE) if (file == XBADFILE)
@ -2729,14 +2737,21 @@ static void* benchmarks_do(void* args)
XFREE(bench_cipher, HEAP_HINT, DYNAMIC_TYPE_WOLF_BIGINT); XFREE(bench_cipher, HEAP_HINT, DYNAMIC_TYPE_WOLF_BIGINT);
bench_cipher = (byte*)XMALLOC((size_t)bench_buf_size, rawSz = bench_buf_size;
if (bench_buf_size % 16)
bench_buf_size += 16 - (bench_buf_size % 16);
if (bench_size > bench_buf_size)
bench_size = bench_buf_size;
bench_cipher = (byte*)XMALLOC((size_t)bench_buf_size + 16*2,
HEAP_HINT, DYNAMIC_TYPE_WOLF_BIGINT); HEAP_HINT, DYNAMIC_TYPE_WOLF_BIGINT);
if (bench_cipher == NULL) if (bench_cipher == NULL)
goto exit; goto exit;
if ((size_t)XFREAD(bench_cipher, 1, bench_buf_size, file) if ((size_t)XFREAD(bench_cipher, 1, rawSz, file)
!= (size_t)bench_buf_size) { != (size_t)rawSz) {
XFCLOSE(file); XFCLOSE(file);
goto exit; goto exit;
} }
@ -4351,9 +4366,9 @@ static void bench_aesecb_internal(int useDeviceID,
double start; double start;
DECLARE_MULTI_VALUE_STATS_VARS() DECLARE_MULTI_VALUE_STATS_VARS()
#ifdef HAVE_FIPS #ifdef HAVE_FIPS
static const int benchSz = AES_BLOCK_SIZE; const int benchSz = AES_BLOCK_SIZE;
#else #else
static const int benchSz = BENCH_SIZE; const int benchSz = (const int)bench_size;
#endif #endif
/* clear for done cleanup */ /* clear for done cleanup */