Skip to content

Commit

Permalink
add labelSz check
Browse files Browse the repository at this point in the history
  • Loading branch information
jpbland1 committed Apr 8, 2024
1 parent 2cfc28b commit d4525d0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/wh_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ int wh_Client_KeyExportResponse(whClientContext* c, uint8_t* label,
uint8_t rawPacket[WH_COMM_MTU] = {0};
whPacket* packet = (whPacket*)rawPacket;
uint8_t* packOut = (uint8_t*)(&packet->keyExportRes + 1);
if (c == NULL || label == NULL || outSz == NULL)
if (c == NULL || labelSz > WOLFHSM_NVM_LABEL_LEN || outSz == NULL)
return WH_ERROR_BADARGS;
ret = wh_Client_RecvResponse(c, &group, &action, &size, rawPacket);
if (ret == 0) {
Expand All @@ -435,10 +435,11 @@ int wh_Client_KeyExportResponse(whClientContext* c, uint8_t* label,
ret = WH_ERROR_ABORTED;
}
else {
XMEMCPY(label, packet->keyExportRes.label, labelSz);
XMEMCPY(out, packOut, packet->keyExportRes.len);
*outSz = packet->keyExportRes.len;
}
if (label != NULL)
XMEMCPY(label, packet->keyExportRes.label, labelSz);
}
}
return ret;
Expand Down

0 comments on commit d4525d0

Please sign in to comment.