git: ec498562b71a - main - crypto: Don't assert for empty output buffers.

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Thu, 09 Dec 2021 20:17:39 UTC
The branch main has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=ec498562b71a5e2baee3556eed7e22947f7abc5d

commit ec498562b71a5e2baee3556eed7e22947f7abc5d
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2021-12-09 19:52:41 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2021-12-09 19:52:41 +0000

    crypto: Don't assert for empty output buffers.
    
    It is always valid for crp_payload_output_start to be 0.  However, if
    an output buffer is empty (e.g. a decryption request with a tag but an
    empty payload), the existing assertion failed since 0 is not less than
    0.
    
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D33193
---
 sys/opencrypto/crypto.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys/opencrypto/crypto.c b/sys/opencrypto/crypto.c
index 8c5457a48f65..cc0e5860c882 100644
--- a/sys/opencrypto/crypto.c
+++ b/sys/opencrypto/crypto.c
@@ -1352,7 +1352,8 @@ crp_sanity(struct cryptop *crp)
 		KASSERT(crp->crp_payload_output_start == 0,
 		    ("payload output start non-zero without output buffer"));
 	} else {
-		KASSERT(crp->crp_payload_output_start < olen,
+		KASSERT(crp->crp_payload_output_start == 0 ||
+		    crp->crp_payload_output_start < olen,
 		    ("invalid payload output start"));
 		KASSERT(crp->crp_payload_output_start +
 		    crp->crp_payload_length <= olen,