diff --git a/libcli/smb/smb2_signing.c b/libcli/smb/smb2_signing.c index d036fd95918..c808f0bda15 100644 --- a/libcli/smb/smb2_signing.c +++ b/libcli/smb/smb2_signing.c @@ -773,12 +773,19 @@ NTSTATUS smb2_signing_decrypt_pdu(struct smb2_signing_key *decryption_key, ctext_size, ptext, &ptext_size); - if (rc < 0 || ptext_size != m_total) { + if (rc < 0) { TALLOC_FREE(ptext); TALLOC_FREE(ctext); status = gnutls_error_to_ntstatus(rc, NT_STATUS_INTERNAL_ERROR); goto out; } + if (ptext_size != m_total) { + TALLOC_FREE(ptext); + TALLOC_FREE(ctext); + rc = GNUTLS_E_SHORT_MEMORY_BUFFER; + status = gnutls_error_to_ntstatus(rc, NT_STATUS_INTERNAL_ERROR); + goto out; + } len = 0; for (i = 1; i < count; i++) {