Skip to content

Commit 77c3380

Browse files
committed
Copilot fixes
1 parent c0073f6 commit 77c3380

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

src/wh_server_crypto.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4785,7 +4785,7 @@ static int _HandleSha256Dma(whServerContext* ctx, uint16_t magic, int devId,
47854785
}
47864786
else {
47874787
/* Validate buffLen from untrusted context */
4788-
if (sha256->buffLen > WC_SHA256_BLOCK_SIZE) {
4788+
if (sha256->buffLen >= WC_SHA256_BLOCK_SIZE) {
47894789
ret = WH_ERROR_BADARGS;
47904790
}
47914791
else {
@@ -4913,7 +4913,7 @@ static int _HandleSha224Dma(whServerContext* ctx, uint16_t magic, int devId,
49134913
}
49144914
else {
49154915
/* Validate buffLen from untrusted context */
4916-
if (sha224->buffLen > WC_SHA224_BLOCK_SIZE) {
4916+
if (sha224->buffLen >= WC_SHA224_BLOCK_SIZE) {
49174917
ret = WH_ERROR_BADARGS;
49184918
}
49194919
else {
@@ -5041,7 +5041,7 @@ static int _HandleSha384Dma(whServerContext* ctx, uint16_t magic, int devId,
50415041
}
50425042
else {
50435043
/* Validate buffLen from untrusted context */
5044-
if (sha384->buffLen > WC_SHA384_BLOCK_SIZE) {
5044+
if (sha384->buffLen >= WC_SHA384_BLOCK_SIZE) {
50455045
ret = WH_ERROR_BADARGS;
50465046
}
50475047
else {
@@ -5169,7 +5169,7 @@ static int _HandleSha512Dma(whServerContext* ctx, uint16_t magic, int devId,
51695169
}
51705170
else {
51715171
/* Validate buffLen from untrusted context */
5172-
if (sha512->buffLen > WC_SHA512_BLOCK_SIZE) {
5172+
if (sha512->buffLen >= WC_SHA512_BLOCK_SIZE) {
51735173
ret = WH_ERROR_BADARGS;
51745174
}
51755175
else {

test/wh_test_clientserver.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -974,9 +974,11 @@ int whTest_ClientServerSequential(whTestNvmBackendType nvmType)
974974
#ifdef WOLFHSM_CFG_DMA
975975
{
976976
/* Register DMA allow list for the buffers used in DMA NVM tests.
977-
* meta is declared here so its address is stable for the allow list */
978-
whNvmMetadata meta = {0};
979-
whServerDmaAddrAllowList nvm_dma_allow = {0};
977+
* static so the server's retained pointer remains valid */
978+
static whNvmMetadata meta;
979+
static whServerDmaAddrAllowList nvm_dma_allow;
980+
memset(&meta, 0, sizeof(meta));
981+
memset(&nvm_dma_allow, 0, sizeof(nvm_dma_allow));
980982
nvm_dma_allow.readList[0].addr = send_buffer;
981983
nvm_dma_allow.readList[0].size = sizeof(send_buffer);
982984
nvm_dma_allow.readList[1].addr = &meta;
@@ -1365,9 +1367,11 @@ int whTest_ClientServerClientConfig(whClientConfig* clientCfg)
13651367
#ifdef WOLFHSM_CFG_DMA
13661368
{
13671369
/* Register DMA allow list for the buffers used in DMA NVM tests.
1368-
* meta is declared here so its address is stable for the allow list */
1369-
whNvmMetadata meta = {0};
1370-
whServerDmaAddrAllowList nvm_dma_allow = {0};
1370+
* static so the server's retained pointer remains valid */
1371+
static whNvmMetadata meta;
1372+
static whServerDmaAddrAllowList nvm_dma_allow;
1373+
memset(&meta, 0, sizeof(meta));
1374+
memset(&nvm_dma_allow, 0, sizeof(nvm_dma_allow));
13711375
nvm_dma_allow.readList[0].addr = send_buffer;
13721376
nvm_dma_allow.readList[0].size = sizeof(send_buffer);
13731377
nvm_dma_allow.readList[1].addr = &meta;

0 commit comments

Comments
 (0)