aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/kern/tty_inq.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/sys/kern/tty_inq.c b/sys/kern/tty_inq.c
index daf3bde77712..0bf7c2fa5b5e 100644
--- a/sys/kern/tty_inq.c
+++ b/sys/kern/tty_inq.c
@@ -165,7 +165,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;
@@ -193,6 +194,14 @@ ttyinq_read_uio(struct ttyinq *ti, struct tty *tp, struct uio *uio,
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.
* - We don't need to read the block until the end, but