DragonFlyBSD Kernel Audit
DF-0661 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/netgraph/ng_device.c b/sys/netgraph/ng_device.c
--- a/sys/netgraph/ng_device.c
+++ b/sys/netgraph/ng_device.c
@@ -506,6 +506,9 @@
 ngdread(cdev_t dev, struct uio *uio, int flag)
 {
 	int ret = 0, amnt;
+
+	if (uio->uio_resid > NGD_QUEUE_SIZE)
+		return(EFBIG);
 	char buffer[uio->uio_resid+1];
 	struct ngd_softc *sc = &ngd_softc;
 	struct ngd_connection * connection = NULL;
@@ -559,8 +562,12 @@
 	int ret;
 	int error = 0;
 	struct mbuf *m;
-	char buffer[uio->uio_resid];
-	int len = uio->uio_resid;
+	int len;
+
+	if (uio->uio_resid > NGD_QUEUE_SIZE)
+		return(EFBIG);
+	len = uio->uio_resid;
+	char buffer[len];
 	struct ngd_softc *sc =& ngd_softc;
 	struct ngd_connection * connection = NULL;
 	struct ngd_connection * tmp;