libcli/smb: Change some checks to SMB_ASSERTS
authorStefan Metzmacher <metze@samba.org>
Mon, 11 Jan 2021 09:01:39 +0000 (10:01 +0100)
committerKarolin Seeger <kseeger@samba.org>
Wed, 20 Jan 2021 09:26:13 +0000 (09:26 +0000)
If we end up here, it's definitely a programming error in the basic
parsing layer of the SMB2 packet.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14607

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
(cherry picked from commit fdcdfceefdd3186ef0b70bb6e83dddc8f4c073db)

libcli/smb/smb2_signing.c

index cc03607d7893b84b892dd826b412dae0324dc4b5..230475480c2c762902d08b0efab9dae5667189cb 100644 (file)
@@ -189,13 +189,8 @@ NTSTATUS smb2_signing_check_pdu(struct smb2_signing_key *signing_key,
        static const uint8_t zero_sig[16] = { 0, };
        int i;
 
-       if (count < 2) {
-               return NT_STATUS_INVALID_PARAMETER;
-       }
-
-       if (vector[0].iov_len != SMB2_HDR_BODY) {
-               return NT_STATUS_INVALID_PARAMETER;
-       }
+       SMB_ASSERT(count >= 2);
+       SMB_ASSERT(vector[0].iov_len == SMB2_HDR_BODY);
 
        hdr = (const uint8_t *)vector[0].iov_base;