From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id A758744643B for ; Thu, 12 Nov 2020 22:52:01 +0300 (MSK) Received: by mail-lf1-f45.google.com with SMTP id 74so10257562lfo.5 for ; Thu, 12 Nov 2020 11:52:01 -0800 (PST) From: Cyrill Gorcunov Date: Thu, 12 Nov 2020 22:51:13 +0300 Message-Id: <20201112195121.191366-4-gorcunov@gmail.com> In-Reply-To: <20201112195121.191366-1-gorcunov@gmail.com> References: <20201112195121.191366-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 03/11] vclock: vclock_inc -- add assert() to catch overflow List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tml Cc: Vladislav Shpilevoy To make sure we won't access out of bounds in lsn array. Signed-off-by: Cyrill Gorcunov --- 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; -- 2.26.2