Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/wh_client_cert.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,17 +327,21 @@ int wh_Client_CertReadTrustedResponse(whClientContext* c, uint8_t* cert,
}

if (resp->rc == WH_ERROR_OK) {
/* Copy certificate data if buffer is large enough */
if (*cert_len >= resp->cert_len) {
memcpy(cert, payload, resp->cert_len);
*cert_len = resp->cert_len;
/* Check that cert_len does not exceed the received data size */
if (resp->cert_len > size - sizeof(*resp)) {
rc = WH_ERROR_ABORTED;
}
else {
/* Check that caller buffer is large enough for the cert */
else if (*cert_len < resp->cert_len) {
*cert_len = resp->cert_len;
if (out_rc != NULL) {
*out_rc = WH_ERROR_BUFFER_SIZE;
}
}
else {
memcpy(cert, payload, resp->cert_len);
*cert_len = resp->cert_len;
}
}
}
}
Expand Down
Loading