summaryrefslogtreecommitdiff
path: root/sys/dev/cons.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2003-06-16 18:44:12 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2003-06-16 18:44:12 +0000
commita3ba645311bbadcd046e18bd4800626c0ebfe100 (patch)
treec87f33b5a85e77c6e3354ab6dd3f120923482310 /sys/dev/cons.c
parent21496f035cdc13c0d7efff86a8529472bf323fff (diff)
Avoid a NULL deref in cnkqfilter() for certain cases. Modeled after
cnwrite(); closes PR 3317.
Diffstat (limited to 'sys/dev/cons.c')
-rw-r--r--sys/dev/cons.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/sys/dev/cons.c b/sys/dev/cons.c
index 9bec1152c02..bfeec64913b 100644
--- a/sys/dev/cons.c
+++ b/sys/dev/cons.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cons.c,v 1.11 2003/06/02 23:28:01 millert Exp $ */
+/* $OpenBSD: cons.c,v 1.12 2003/06/16 18:44:11 millert Exp $ */
/* $NetBSD: cons.c,v 1.30 1996/04/08 19:57:30 jonathan Exp $ */
/*
@@ -229,12 +229,17 @@ cnkqfilter(dev, kn)
dev_t dev;
struct knote *kn;
{
+
+ /*
+ * Redirect output, if that's appropriate.
+ * If there's no real console, return 1.
+ */
if (constty != NULL && (cn_tab == NULL || cn_tab->cn_pri != CN_REMOTE))
- return 0;
- if (cn_tab == NULL)
+ dev = constty->t_dev;
+ else if (cn_tab == NULL)
return (1);
-
- dev = cn_tab->cn_dev;
+ else
+ dev = cn_tab->cn_dev;
if (cdevsw[major(dev)].d_type & D_KQFILTER)
return ((*cdevsw[major(dev)].d_kqfilter)(dev, kn));
return (1);
@@ -297,4 +302,3 @@ cnbell(pitch, period, volume)
(*cn_tab->cn_bell)(cn_tab->cn_dev, pitch, period, volume);
}
-