From 718f44ae5b6f07dafd43efca1fc642be0716cb86 Mon Sep 17 00:00:00 2001 From: Christian Helmuth Date: Wed, 5 May 2021 15:02:30 +0200 Subject: [PATCH] Check max_len before dereferencing pointer in Cstring constructor Fixes #4112 --- repos/base/include/util/string.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repos/base/include/util/string.h b/repos/base/include/util/string.h index 5e41b53d76..eb852fa0f0 100644 --- a/repos/base/include/util/string.h +++ b/repos/base/include/util/string.h @@ -552,7 +552,7 @@ class Genode::Cstring * null once we reach 'max_len'. */ size_t res = 0; - for (; str && *str && res < max_len; str++, res++); + for (; res < max_len && str && *str; str++, res++); return res; }