mirror of
https://github.com/genodelabs/genode.git
synced 2025-05-04 01:33:02 +00:00
base: string length handling fix in Rpc_in_buffer
If a null-terminated string exactly of length MAX (0 byte included) is provided, it will be handled as invalid because of wrong string size length checks. Commit fixes this. Discovered during #1486 development.
This commit is contained in:
parent
3c5fb420ca
commit
0ed45d92ff
@ -88,8 +88,8 @@ class Genode::Rpc_in_buffer : public Rpc_in_buffer_base
|
|||||||
*/
|
*/
|
||||||
Rpc_in_buffer(const char *str) : Rpc_in_buffer_base(str)
|
Rpc_in_buffer(const char *str) : Rpc_in_buffer_base(str)
|
||||||
{
|
{
|
||||||
if (_size >= MAX_SIZE - 1)
|
if (_size >= MAX_SIZE)
|
||||||
_size = MAX_SIZE - 1;
|
_size = MAX_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -107,7 +107,7 @@ class Genode::Rpc_in_buffer : public Rpc_in_buffer_base
|
|||||||
* Return true if buffer contains a valid null-terminated string
|
* Return true if buffer contains a valid null-terminated string
|
||||||
*/
|
*/
|
||||||
bool is_valid_string() const {
|
bool is_valid_string() const {
|
||||||
return (_size < MAX_SIZE) && (_size > 0) && (_base[_size - 1] == '\0'); }
|
return (_size <= MAX_SIZE) && (_size > 0) && (_base[_size - 1] == '\0'); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return buffer content as null-terminated string
|
* Return buffer content as null-terminated string
|
||||||
|
Loading…
x
Reference in New Issue
Block a user