Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #424: Coverity: Dereference null return value #425

Merged
merged 2 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,8 @@ public void processResponse(StepContext<M, R> stepContext) throws Exception { }
* @throws Exception when an error during response processing occurred
*/
public final void processResponse(StepContext<M, R> stepContext, byte[] responseBody, Class<R> responseObjectClass) throws Exception {
R responseBodyObject = HttpUtil.fromBytes(responseBody, responseObjectClass);
ResponseEntity<R> responseEntity = ResponseEntity.of(Optional.of(responseBodyObject));
final R responseBodyObject = HttpUtil.fromBytes(responseBody, responseObjectClass);
final ResponseEntity<R> responseEntity = ResponseEntity.ofNullable(responseBodyObject);
addResponseContext(stepContext, responseEntity);
processResponse(stepContext);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.stereotype.Component;

import javax.crypto.SecretKey;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -144,7 +145,16 @@ public void processResponse(StepContext<GetStatusStepModel, ObjectResponse<Activ
final Map<String, Object> customObject = responseObject.getCustomObject();
byte[] challenge = (byte[]) stepContext.getAttributes().get(ATTRIBUTE_CHALLENGE);

final ActivationStatusBlobInfo statusBlobRaw = ACTIVATION.getStatusFromEncryptedBlob(cStatusBlob, challenge, cStatusBlobNonce, resultStatusObject.getTransportMasterKeyObject());
final SecretKey transportMasterKey = resultStatusObject.getTransportMasterKeyObject();
if (transportMasterKey == null) {
stepContext.getStepLogger().writeError(
getStep().id() + "-failed",
"Get Status Failed",
"transportMasterKey is null");
return;
}

final ActivationStatusBlobInfo statusBlobRaw = ACTIVATION.getStatusFromEncryptedBlob(cStatusBlob, challenge, cStatusBlobNonce, transportMasterKey);
final ExtendedActivationStatusBlobInfo statusBlob = ExtendedActivationStatusBlobInfo.copy(statusBlobRaw);

final Map<String, Object> objectMap = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,15 @@ public void processResponse(StepContext<VaultUnlockStepModel, EciesEncryptedResp

ResultStatusObject resultStatusObject = stepContext.getModel().getResultStatus();

SecretKey transportMasterKey = resultStatusObject.getTransportMasterKeyObject();
final SecretKey transportMasterKey = resultStatusObject.getTransportMasterKeyObject();
if (transportMasterKey == null) {
stepContext.getStepLogger().writeError(
getStep().id() + "-vault-unlock-failed",
"Vault Unlock Failed",
"transportMasterKey is null");
return;
}

byte[] encryptedDevicePrivateKeyBytes = resultStatusObject.getEncryptedDevicePrivateKeyBytes();

byte[] encryptedVaultEncryptionKey = Base64.getDecoder().decode(responsePayload.getEncryptedVaultEncryptionKey());
Expand Down
Loading