[Tarantool-patches] [PATCH 03/11] vclock: vclock_inc -- add assert() to catch overflow
Serge Petrenko
sergepetrenko at tarantool.org
Fri Nov 13 12:30:53 MSK 2020
12.11.2020 22:51, Cyrill Gorcunov пишет:
> To make sure we won't access out of bounds in lsn array.
>
> Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
> ---
> src/lib/vclock/vclock.h | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/src/lib/vclock/vclock.h b/src/lib/vclock/vclock.h
> index fd4072c94..09521a393 100644
> --- a/src/lib/vclock/vclock.h
> +++ b/src/lib/vclock/vclock.h
> @@ -169,6 +169,7 @@ vclock_get(const struct vclock *vclock, uint32_t replica_id)
> static inline int64_t
> vclock_inc(struct vclock *vclock, uint32_t replica_id)
> {
> + assert(replica_id < VCLOCK_MAX);
> /* Easier add each time than check. */
> if (((vclock->map >> replica_id) & 0x01) == 0) {
> vclock->lsn[replica_id] = 0;
LGTM
--
Serge Petrenko
More information about the Tarantool-patches
mailing list