summaryrefslogtreecommitdiffstats
path: root/sys/kern/tty_pty.c
diff options
context:
space:
mode:
authorjmg <jmg@FreeBSD.org>1997-07-30 10:05:18 +0000
committerjmg <jmg@FreeBSD.org>1997-07-30 10:05:18 +0000
commit6422ff53131fb15f8dddd942b7e7365fca90de76 (patch)
tree7bcf05016ccf62cf4410b8798ed59541cc026aa9 /sys/kern/tty_pty.c
parent9157a090b3e0beb23a1a26d1a2fad9ac2d2a8bf8 (diff)
downloadFreeBSD-src-6422ff53131fb15f8dddd942b7e7365fca90de76.zip
FreeBSD-src-6422ff53131fb15f8dddd942b7e7365fca90de76.tar.gz
fix a few problems with pty. warn about how if you only have 1 pty
defined, your really getting 32. Also warn about how you can't have more than 256 pty's when your using DEVFS (non DEVFS can use more, just the makedev script doesn't know how to make >256). it also doesn't allocate more memory than needed in this case. Make sure that the signal passed in TIOCSIG isn't 0 as it might cause a panic. I personally haven't seen this happen, but after a similar bug in syscons crashed my machine, I'm acutely aware of this one. :)
Diffstat (limited to 'sys/kern/tty_pty.c')
-rw-r--r--sys/kern/tty_pty.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/sys/kern/tty_pty.c b/sys/kern/tty_pty.c
index ee0b653..f721b41 100644
--- a/sys/kern/tty_pty.c
+++ b/sys/kern/tty_pty.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)tty_pty.c 8.4 (Berkeley) 2/20/95
- * $Id: tty_pty.c,v 1.42 1997/03/23 03:36:28 bde Exp $
+ * $Id: tty_pty.c,v 1.43 1997/03/24 12:03:06 bde Exp $
*/
/*
@@ -93,6 +93,19 @@ static struct cdevsw ptc_cdevsw =
#if NPTY == 1
#undef NPTY
#define NPTY 32 /* crude XXX */
+#warning You have only one pty defined, redefining to 32.
+#endif
+
+#ifdef DEVFS
+#define MAXUNITS (8 * 32)
+static void *devfs_token_pts[MAXUNITS];
+static void *devfs_token_ptc[MAXUNITS];
+static const char jnames[] = "pqrsPQRS";
+#if NPTY > MAXUNITS
+#undef NPTY
+#define NPTY MAXUNITS
+#warning Can't have more than 256 pty's with DEVFS defined.
+#endif
#endif
#define BUFSIZ 100 /* Chunk size iomoved to/from user */
@@ -710,7 +723,8 @@ ptyioctl(dev, cmd, data, flag, p)
break;
case TIOCSIG:
- if (*(unsigned int *)data >= NSIG)
+ if (*(unsigned int *)data >= NSIG ||
+ *(unsigned int *)data == 0)
return(EINVAL);
if ((tp->t_lflag&NOFLSH) == 0)
ttyflush(tp, FREAD|FWRITE);
@@ -780,12 +794,6 @@ ptyioctl(dev, cmd, data, flag, p)
}
static ptc_devsw_installed = 0;
-#ifdef DEVFS
-#define MAXUNITS (8 * 32)
-static void *devfs_token_pts[MAXUNITS];
-static void *devfs_token_ptc[MAXUNITS];
-static const char jnames[] = "pqrsPQRS";
-#endif
static void
ptc_drvinit(void *unused)
@@ -802,11 +810,6 @@ ptc_drvinit(void *unused)
cdevsw_add(&dev, &ptc_cdevsw, NULL);
ptc_devsw_installed = 1;
#ifdef DEVFS
-/*XXX*/
-#if NPTY > MAXUNITS
-#undef NPTY
-#define NPTY MAXUNITS
-#endif
for ( i = 0 ; i<NPTY ; i++ ) {
j = i / 32;
k = i % 32;
OpenPOWER on IntegriCloud