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.
This commit is contained in:
Norman Feske 2012-01-28 02:54:29 +01:00
parent 36be5ec4b0
commit da5bf709e6
1 changed files with 6 additions and 3 deletions

View File

@ -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;
}