mirror of https://github.com/wolfSSL/wolfssh.git
Fix NULL pointer dereference in wolfSSH_SetTpmDev/SetTpmKey
Move the NULL validation checks inside the existing NULL guards for ssh and ssh->ctx. Previously, the check accessed ssh->ctx outside the guard, causing a NULL dereference when ssh or ssh->ctx was NULL. Also fix wolfSSH_SetTpmKey to check tpmKey instead of tpmDev.pull/880/head
parent
99319bf773
commit
82b9f1138d
14
src/ssh.c
14
src/ssh.c
|
|
@ -405,11 +405,12 @@ void wolfSSH_SetTpmDev(WOLFSSH* ssh, WOLFTPM2_DEV* dev)
|
|||
{
|
||||
WLOG(WS_LOG_DEBUG, "Entering wolfSSH_SetTpmDev()");
|
||||
|
||||
if (ssh && ssh->ctx)
|
||||
if (ssh && ssh->ctx) {
|
||||
ssh->ctx->tpmDev = dev;
|
||||
|
||||
if (ssh->ctx->tpmDev == NULL) {
|
||||
WLOG(WS_LOG_DEBUG, "wolfSSH_SetTpmDev: Set tpm dev failed");
|
||||
if (ssh->ctx->tpmDev == NULL) {
|
||||
WLOG(WS_LOG_DEBUG, "wolfSSH_SetTpmDev: Set tpm dev failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -418,11 +419,12 @@ void wolfSSH_SetTpmKey(WOLFSSH* ssh, WOLFTPM2_KEY* key)
|
|||
{
|
||||
WLOG(WS_LOG_DEBUG, "Entering wolfSSH_SetTpmKey()");
|
||||
|
||||
if (ssh && ssh->ctx)
|
||||
if (ssh && ssh->ctx) {
|
||||
ssh->ctx->tpmKey = key;
|
||||
|
||||
if (ssh->ctx->tpmDev == NULL) {
|
||||
WLOG(WS_LOG_DEBUG, "wolfSSH_SetTpmKey: Set tpm key failed");
|
||||
if (ssh->ctx->tpmKey == NULL) {
|
||||
WLOG(WS_LOG_DEBUG, "wolfSSH_SetTpmKey: Set tpm key failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue