trace_buffer: fix out-of-bounds read

The calculation in next() actually checked whether the current entry
fitted into the buffer, not if another one fitted.

genodelabs/genode#4430
This commit is contained in:
Johannes Schlatow 2022-02-17 12:01:03 +01:00 committed by Christian Helmuth
parent d7c4265089
commit 44aefc8777

View File

@ -170,7 +170,7 @@ class Genode::Trace::Buffer
if (entry.length() == 0)
return Entry(0);
addr_t const offset = (addr_t)entry._entry - (addr_t)_entries;
addr_t const offset = (addr_t)entry.data() - (addr_t)_entries;
if (offset + entry.length() + sizeof(_Entry) > _size)
return Entry(0);