diff --git a/sys/kern/tty_inq.c b/sys/kern/tty_inq.c --- a/sys/kern/tty_inq.c +++ b/sys/kern/tty_inq.c @@ -164,7 +164,8 @@ 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 @@ 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.