summaryrefslogtreecommitdiffstats
path: root/linux
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2021-12-04 20:22:51 +0100
committerBenBE <BenBE@geshi.org>2021-12-05 19:28:07 +0100
commit61c9fe44a3c31aaab14ec01c568ecf2f081e1bdf (patch)
tree922aa3dd875cb8254eacd21706d7c7d5908bd967 /linux
parentff0ea41c869fa5ae84c75fc261f3e81a693e3c02 (diff)
CGroupUtils: avoid unsigned integer underflow
Do not underflow count at the last iteration, which triggers UBSAN when using -fsanitize=unsigned-integer-overflow. This is useful as those underflows can be a result of a flawed counting logic (e.g. a counter gets reduced more than increased).
Diffstat (limited to 'linux')
-rw-r--r--linux/CGroupUtils.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/linux/CGroupUtils.c b/linux/CGroupUtils.c
index 6f3b6fe7..765012d3 100644
--- a/linux/CGroupUtils.c
+++ b/linux/CGroupUtils.c
@@ -33,7 +33,7 @@ static bool StrBuf_putc_write(StrBuf_state* p, char c) {
}
static bool StrBuf_putsn(StrBuf_state* p, StrBuf_putc_t w, const char* s, size_t count) {
- while (count--)
+ for (; count; count--)
if (!w(p, *s++))
return false;

© 2014-2024 Faster IT GmbH | imprint | privacy policy