• Peter Hurley's avatar
    n_tty: Fix 4096-byte canonical reads · c77569d2
    Peter Hurley authored
    Although the maximum allowable canonical line is specified to
    be 255 bytes (MAX_CANON), the practical limit has actually been
    the size of the line discipline read buffer (N_TTY_BUF_SIZE == 4096).
    
    Commit 32f13521,
    n_tty: Line copy to user buffer in canonical mode, limited the
    line copy to 4095 bytes. With a completely full line discipline
    read buffer and a userspace buffer > 4095, _no_ data was copied,
    and the read() syscall returned 0, indicating EOF.
    
    Fix the interval arithmetic to compute the correct number of bytes
    to copy to userspace in the range [1..4096].
    
    Cc: <stable@vger.kernel.org> # 3.12.x
    Signed-off-by: default avatarPeter Hurley <peter@hurleysoftware.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    c77569d2
n_tty.c 60.7 KB