]> git.ipfire.org Git - thirdparty/gcc.git/commit
wide-int: Add simple CHECKING_P stack-protector canary like checking
authorJakub Jelinek <jakub@redhat.com>
Thu, 12 Oct 2023 14:07:25 +0000 (16:07 +0200)
committerJakub Jelinek <jakub@redhat.com>
Thu, 12 Oct 2023 14:07:25 +0000 (16:07 +0200)
commitfb590e4eeb1aa897209b853430dc4854ece97802
treedfed0714e41cd12bdf545d85d1cef598be58d5c5
parent0d00385eaf72ccacff17935b0d214a26773e095f
wide-int: Add simple CHECKING_P stack-protector canary like checking

This patch adds hopefully not so expensive --enable-checking=yes
verification that the widest_int upper length bound estimates are really
upper bounds and nothing attempts to write more elements.
It is done only if the estimated upper length bound is smaller than
WIDE_INT_MAX_INL_ELTS, but that should be the most common case unless
large _BitInt is involved.

2023-10-12  Jakub Jelinek  <jakub@redhat.com>

* wide-int.h (widest_int_storage <N>::write_val): If l is small
and there is space in u.val array, store a canary value at the
end when checking.
(widest_int_storage <N>::set_len): Check the canary hasn't been
overwritten.
gcc/wide-int.h