From da5bf709e6450f2c6927ca2245ec82534a577850 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Sat, 28 Jan 2012 02:54:29 +0100 Subject: [PATCH] Consider count_in in Noux terminal-read function It does not suffice to constrain the amount of returned data with chunk size of the transport buffer because the client may have specified an even smaller value. For example, libreadline reads single characters from the terminal and expects a single character in return. A different amount is interpreted as EOF. --- ports/src/noux/terminal_io_channel.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ports/src/noux/terminal_io_channel.h b/ports/src/noux/terminal_io_channel.h index d1e3daaf5..b91d1526d 100644 --- a/ports/src/noux/terminal_io_channel.h +++ b/ports/src/noux/terminal_io_channel.h @@ -64,9 +64,12 @@ namespace Noux { return false; } - Genode::size_t count = terminal.read(sysio->read_out.chunk, - sizeof(sysio->read_out.chunk)); - sysio->read_out.count = count; + Genode::size_t const max_count = + Genode::min(sysio->read_in.count, + sizeof(sysio->read_out.chunk)); + + sysio->read_out.count = + terminal.read(sysio->read_out.chunk, max_count); return true; }