From 0ed45d92fff16ca42c2cfabe2a34557d39f55ad0 Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Thu, 9 Apr 2015 11:35:22 +0200 Subject: [PATCH] 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. --- repos/base/include/base/rpc_args.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/repos/base/include/base/rpc_args.h b/repos/base/include/base/rpc_args.h index a70869be4..9935172e7 100644 --- a/repos/base/include/base/rpc_args.h +++ b/repos/base/include/base/rpc_args.h @@ -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) { - if (_size >= MAX_SIZE - 1) - _size = MAX_SIZE - 1; + if (_size >= MAX_SIZE) + _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 */ 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