diff options
author | bde <bde@FreeBSD.org> | 1996-04-11 18:43:37 +0000 |
---|---|---|
committer | bde <bde@FreeBSD.org> | 1996-04-11 18:43:37 +0000 |
commit | f48cd2e7e2cd638113996259ba37673e880cd33e (patch) | |
tree | 06248b1618489ad63825a235181edb36cb688a49 /sys/kern | |
parent | b99b299984fd0197cd68c9737aaf903c2c585a45 (diff) | |
download | FreeBSD-src-f48cd2e7e2cd638113996259ba37673e880cd33e.zip FreeBSD-src-f48cd2e7e2cd638113996259ba37673e880cd33e.tar.gz |
Fixed the PF_REMOTE case of ptcwrite(). I broke it in rev.1.22. Output
was duplicated until the canq filled up, and write() normally returned 0.
This case is apparently rare. It was reported for Jove's shell buffer in
PR 1130.
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/tty_pty.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/sys/kern/tty_pty.c b/sys/kern/tty_pty.c index 3559ec3..2918d3d 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.38 1996/02/29 00:18:11 hsu Exp $ + * $Id: tty_pty.c,v 1.37 1996/03/11 02:24:39 hsu Exp $ */ /* @@ -534,8 +534,19 @@ again: return (EIO); } } - if (cc) - cc -= b_to_q((char *)cp, cc, &tp->t_canq); + if (cc > 0) { + cc = b_to_q((char *)cp, cc, &tp->t_canq); + /* + * XXX we don't guarantee that the canq size + * is >= TTYHOG, so the above b_to_q() may + * leave some bytes uncopied. However, space + * is guaranteed for the null terminator if + * we don't fail here since (TTYHOG - 1) is + * not a multiple of CBSIZE. + */ + if (cc > 0) + break; + } } /* adjust for data copied in but not written */ uio->uio_resid += cc; @@ -574,7 +585,7 @@ again: block: /* * Come here to wait for slave to open, for space - * in outq, or space in rawq. + * in outq, or space in rawq, or an empty canq. */ if ((tp->t_state & TS_CONNECTED) == 0) { /* adjust for data copied in but not written */ |