FreeBSD Bugzilla – Attachment 247547 Details for
Bug 276220
tty_disc canonical input processing: suprising behavior of the EOF cchar
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
git(1) diff against base
tty.diff (text/plain), 1.97 KB, created by
Kyle Evans
on 2024-01-09 17:58:09 UTC
(
hide
)
Description:
git(1) diff against base
Filename:
MIME Type:
Creator:
Kyle Evans
Created:
2024-01-09 17:58:09 UTC
Size:
1.97 KB
patch
obsolete
>diff --git a/sys/kern/tty_inq.c b/sys/kern/tty_inq.c >index 1a31d8b7fa2b..2eed9802a7b7 100644 >--- a/sys/kern/tty_inq.c >+++ b/sys/kern/tty_inq.c >@@ -164,7 +164,8 @@ ttyinq_read_uio(struct ttyinq *ti, struct tty *tp, struct uio *uio, > size_t rlen, size_t flen) > { > >- MPASS(rlen <= uio->uio_resid); >+ /* rlen includes flen, flen bytes will be trimmed from the end. */ >+ MPASS(rlen - flen <= uio->uio_resid); > > while (rlen > 0) { > int error; >@@ -191,6 +192,14 @@ ttyinq_read_uio(struct ttyinq *ti, struct tty *tp, struct uio *uio, > MPASS(clen >= flen); > rlen -= clen; > >+ /* >+ * Caller shouldn't request that we trim anything if we might be >+ * reading across blocks. We could handle it, but today we do >+ * not. >+ */ >+ if (flen > 0) >+ MPASS(rlen == 0); >+ > /* > * We can prevent buffering in some cases: > * - We need to read the block until the end. >diff --git a/sys/kern/tty_ttydisc.c b/sys/kern/tty_ttydisc.c >index 3016f5e4ccb5..8db9e9d5d026 100644 >--- a/sys/kern/tty_ttydisc.c >+++ b/sys/kern/tty_ttydisc.c >@@ -153,7 +153,7 @@ ttydisc_read_canonical(struct tty *tp, struct uio *uio, int ioflag) > * cause the TTY layer to return data in chunks using > * the blocksize (except the first and last blocks). > */ >- clen = ttyinq_findchar(&tp->t_inq, breakc, uio->uio_resid, >+ clen = ttyinq_findchar(&tp->t_inq, breakc, uio->uio_resid + 1, > &lastc); > > /* No more data. */ >@@ -169,10 +169,15 @@ ttydisc_read_canonical(struct tty *tp, struct uio *uio, int ioflag) > continue; > } > >- /* Don't send the EOF char back to userspace. */ >+ /* >+ * Don't send the EOF char back to userspace. Our above call to >+ * ttyinq_findchar overreads by 1 character in case we would >+ * otherwise be leaving an EOF for the next read(). We'll trim >+ * clen back down to uio_resid whether we find our EOF or not. >+ */ > if (CMP_CC(VEOF, lastc)) > flen = 1; >- >+ clen = MIN(uio->uio_resid + flen, clen); > MPASS(flen <= clen); > > /* Read and throw away the EOF character. */
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 276220
: 247547