⬢ DragonFlyBSD Kernel Audit
DF-4638 / fix.diff
← back to finding ↓ download raw
--- a/sys/dev/netif/ig_hal/e1000_mbx.c
+++ b/sys/dev/netif/ig_hal/e1000_mbx.c
@@ -253,6 +253,10 @@
 	if (!mbx->ops.read)
 		goto out;
 
+	/* limit read to size of mailbox */
+	if (size > mbx->size)
+		size = mbx->size;
+
 	ret_val = e1000_poll_for_msg(hw, mbx_id);
 
 	/* if ack received read message, otherwise we timed out */
@@ -279,8 +283,9 @@
 
 	DEBUGFUNC("e1000_write_posted_mbx");
 
-	/* exit if either we can't write or there isn't a defined timeout */
-	if (!mbx->ops.write || !mbx->timeout)
+	/* exit if we can't write, there is no timeout, or the message
+	 * won't fit in the mailbox */
+	if (!mbx->ops.write || !mbx->timeout || size > mbx->size)
 		goto out;
 
 	/* send msg */