diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2022-04-30 14:51:10 +0200 |
---|---|---|
committer | BenBE <BenBE@geshi.org> | 2022-05-05 09:19:14 +0200 |
commit | 549fcb6bb8797a5fe981d484b84ffca23226655e (patch) | |
tree | 671bc5201f1e26688283a01d12d28eea26ae3224 | |
parent | 08166b27b191e7be62d74054d92a9720c3a141ab (diff) |
Always abort on overflow in String_cat
Not only in debug mode.
-rw-r--r-- | XUtils.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -115,7 +115,9 @@ inline bool String_contains_i(const char* s1, const char* s2, bool multi) { char* String_cat(const char* s1, const char* s2) { const size_t l1 = strlen(s1); const size_t l2 = strlen(s2); - assert(SIZE_MAX - l1 > l2); + if (SIZE_MAX - l1 <= l2) { + fail(); + } char* out = xMalloc(l1 + l2 + 1); memcpy(out, s1, l1); memcpy(out + l1, s2, l2); |