mirror of https://github.com/acidanthera/audk.git
NetworkPkg/IScsiDxe: assert that IScsiBinToHex() always succeeds
IScsiBinToHex() is called for encoding: - the answer to the target's challenge; that is, CHAP_R; - the challenge for the target, in case mutual authentication is enabled; that is, CHAP_C. The initiator controls the size of both blobs, the sizes of their hex encodings are correctly calculated in "RspLen" and "ChallengeLen". Therefore the IScsiBinToHex() calls never fail; assert that. Cc: Jiaxin Wu <jiaxin.wu@intel.com> Cc: Maciej Rabeda <maciej.rabeda@linux.intel.com> Cc: Philippe Mathieu-Daudé <philmd@redhat.com> Cc: Siyuan Fu <siyuan.fu@intel.com> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3356 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Maciej Rabeda <maciej.rabeda@linux.intel.com> Message-Id: <20210608121259.32451-7-lersek@redhat.com>
This commit is contained in:
parent
cf01b2dc8f
commit
d90fff40cb
|
@ -391,6 +391,7 @@ IScsiCHAPToSendReq (
|
||||||
UINT32 RspLen;
|
UINT32 RspLen;
|
||||||
CHAR8 *Challenge;
|
CHAR8 *Challenge;
|
||||||
UINT32 ChallengeLen;
|
UINT32 ChallengeLen;
|
||||||
|
EFI_STATUS BinToHexStatus;
|
||||||
|
|
||||||
ASSERT (Conn->CurrentStage == ISCSI_SECURITY_NEGOTIATION);
|
ASSERT (Conn->CurrentStage == ISCSI_SECURITY_NEGOTIATION);
|
||||||
|
|
||||||
|
@ -471,12 +472,13 @@ IScsiCHAPToSendReq (
|
||||||
//
|
//
|
||||||
// CHAP_R=<R>
|
// CHAP_R=<R>
|
||||||
//
|
//
|
||||||
IScsiBinToHex (
|
BinToHexStatus = IScsiBinToHex (
|
||||||
(UINT8 *) AuthData->CHAPResponse,
|
(UINT8 *) AuthData->CHAPResponse,
|
||||||
ISCSI_CHAP_RSP_LEN,
|
ISCSI_CHAP_RSP_LEN,
|
||||||
Response,
|
Response,
|
||||||
&RspLen
|
&RspLen
|
||||||
);
|
);
|
||||||
|
ASSERT_EFI_ERROR (BinToHexStatus);
|
||||||
IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_RESPONSE, Response);
|
IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_RESPONSE, Response);
|
||||||
|
|
||||||
if (AuthData->AuthConfig->CHAPType == ISCSI_CHAP_MUTUAL) {
|
if (AuthData->AuthConfig->CHAPType == ISCSI_CHAP_MUTUAL) {
|
||||||
|
@ -490,12 +492,13 @@ IScsiCHAPToSendReq (
|
||||||
// CHAP_C=<C>
|
// CHAP_C=<C>
|
||||||
//
|
//
|
||||||
IScsiGenRandom ((UINT8 *) AuthData->OutChallenge, ISCSI_CHAP_RSP_LEN);
|
IScsiGenRandom ((UINT8 *) AuthData->OutChallenge, ISCSI_CHAP_RSP_LEN);
|
||||||
IScsiBinToHex (
|
BinToHexStatus = IScsiBinToHex (
|
||||||
(UINT8 *) AuthData->OutChallenge,
|
(UINT8 *) AuthData->OutChallenge,
|
||||||
ISCSI_CHAP_RSP_LEN,
|
ISCSI_CHAP_RSP_LEN,
|
||||||
Challenge,
|
Challenge,
|
||||||
&ChallengeLen
|
&ChallengeLen
|
||||||
);
|
);
|
||||||
|
ASSERT_EFI_ERROR (BinToHexStatus);
|
||||||
IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_CHALLENGE, Challenge);
|
IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_CHALLENGE, Challenge);
|
||||||
|
|
||||||
Conn->AuthStep = ISCSI_CHAP_STEP_FOUR;
|
Conn->AuthStep = ISCSI_CHAP_STEP_FOUR;
|
||||||
|
|
Loading…
Reference in New Issue