]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
kern: tty: fix ttyinq_read_uio assertion
authorKyle Evans <kevans@FreeBSD.org>
Tue, 16 Jan 2024 02:55:58 +0000 (20:55 -0600)
committerKyle Evans <kevans@FreeBSD.org>
Tue, 16 Jan 2024 02:55:58 +0000 (20:55 -0600)
commit09a43b8790bdeb97fbecd3ea767c2f599eb4a4d3
tree09aaf72577505878be2c97b542aad9a97c38112a
parent08efe9bef43b784b3cd4f22252a8f908f448895b
kern: tty: fix ttyinq_read_uio assertion

It's clear from later context that `rlen` was always expected to include
`flen`, as we'll trim `flen` bytes from the end of the read.  Relax our
initial assertion to only require the total size less trimmed bytes to
lie within the out buffer size.

While we're here, I note that if we have to read more than one block and
we're trimming from the end then we'll do the wrong thing and omit
`flen` bytes from every block, rather than just the end.  Add an
assertion to make sure we're not doing that, but the only caller that
specifies a non-zero `flen` today will only really be doing so if rlen
is entirely within a single buffer.

Reviewed by: cy, imp
Differential Revision: https://reviews.freebsd.org/D43377
sys/kern/tty_inq.c