diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2021-12-04 20:22:51 +0100 |
---|---|---|
committer | BenBE <BenBE@geshi.org> | 2021-12-05 19:28:07 +0100 |
commit | 61c9fe44a3c31aaab14ec01c568ecf2f081e1bdf (patch) | |
tree | 922aa3dd875cb8254eacd21706d7c7d5908bd967 /linux | |
parent | ff0ea41c869fa5ae84c75fc261f3e81a693e3c02 (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.c | 2 |
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; |