mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-22 15:02:25 +00:00
terminal: fix condition in zero-character handling
The condition must first check the io-buffer length and then check the content. Otherwise, cat'ting a file that is padded with zeros up to page size (io-buffer size) yields an out-of-range read access.
This commit is contained in:
parent
1f1302e185
commit
13419755f9
@ -104,13 +104,18 @@ class Terminal::Session_component : public Rpc_object<Session, Session_component
|
||||
|
||||
unsigned i = 0;
|
||||
for (Utf8_ptr utf8(src); utf8.complete() && i < max; ) {
|
||||
|
||||
_character_consumer.consume_character(utf8.codepoint().value);
|
||||
|
||||
i += utf8.length();
|
||||
if (i >= max)
|
||||
break;
|
||||
|
||||
utf8 = Utf8_ptr(src + i);
|
||||
}
|
||||
|
||||
/* consume trailing zero characters */
|
||||
for (; src[i] == 0 && i < num_bytes; i++);
|
||||
for (; i < max && src[i] == 0; i++);
|
||||
|
||||
/* we don't support UTF-8 sequences split into multiple writes */
|
||||
if (i != num_bytes) {
|
||||
|
Loading…
Reference in New Issue
Block a user