⬢ DragonFlyBSD Kernel Audit
DF-2407 / fix.diff
← back to finding ↓ download raw
# DF-2407 fix (authored post-verification; not applied to sys/)
--- a/sys/dev/crypto/tpm/tpm.c
+++ b/sys/dev/crypto/tpm/tpm.c
@@ -816,7 +816,7 @@ tpm_tis12_write(struct tpm_softc *sc, void *buf, int len)
 	if ((rv = tpm_request_locality(sc, 0)) != 0)
 		return rv;
 
-	cnt = 0;
-	while (cnt < len - 1) {
+	cnt = 0;
+	while (len > 0 && cnt < (size_t)len - 1) {