Skip to content

Commit 9e532c2

Browse files
committed
Fixes for a couple of fsanitize warnings. Fix for possible leak with large request to IntelQaDrbg.
1 parent 2c4b751 commit 9e532c2

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

wolfcrypt/src/port/intel/quickassist.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3404,10 +3404,15 @@ int IntelQaDrbg(WC_ASYNC_DEV* dev, byte* rngBuf, word32 rngSz)
34043404
gen = 0xFFFF;
34053405

34063406
pOut->dataLenInBytes = gen;
3407-
pOut->pData = XREALLOC(&rngBuf[idx], gen, dev->heap,
3408-
DYNAMIC_TYPE_ASYNC_NUMA);
3409-
if (pOut->pData == NULL) {
3410-
ret = MEMORY_E; goto exit;
3407+
if (idx == 0 && pOut->pData == NULL) {
3408+
pOut->pData = XREALLOC(rngBuf, gen, dev->heap,
3409+
DYNAMIC_TYPE_ASYNC_NUMA);
3410+
if (pOut->pData == NULL) {
3411+
ret = MEMORY_E; goto exit;
3412+
}
3413+
}
3414+
else {
3415+
XMEMCPY(pOut->pData, &rngBuf[idx], gen);
34113416
}
34123417

34133418
opData->sessionHandle = dev->qat.op.drbg.handle;

wolfcrypt/src/port/intel/quickassist_mem.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,8 @@ static void* _qaeMemAlloc(size_t size, void* heap, int type
374374
/* allocate type */
375375
if (isNuma) {
376376
/* Node is typically 0 */
377-
ptr = qaeMemAllocNUMA(size + sizeof(qaeMemHeader), 0, alignment,
378-
&page_offset);
377+
ptr = qaeMemAllocNUMA((Cpa32U)(size + sizeof(qaeMemHeader)), 0,
378+
alignment, &page_offset);
379379
}
380380
if (ptr == NULL) {
381381
isNuma = 0;

0 commit comments

Comments
 (0)