Tarantool development patches archive
 help / color / mirror / Atom feed
From: Cyrill Gorcunov <gorcunov@gmail.com>
To: tml <tarantool-patches@dev.tarantool.org>
Cc: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Subject: [Tarantool-patches] [PATCH v6 4/5] cfg: more precise check for replication_synchro_quorum value
Date: Tue, 22 Dec 2020 14:14:07 +0300	[thread overview]
Message-ID: <20201222111408.48368-5-gorcunov@gmail.com> (raw)
In-Reply-To: <20201222111408.48368-1-gorcunov@gmail.com>

When we fetch replication_synchro_quorum value (either as
a plain integer or via formula evaluation) we trim the
number down to integer, which silently hides potential
overflow errors.

For example

 | box.cfg{replication_synchro_quorum='4294967297'}

which is 1 in terms of machine words. Lets use 8 bytes
values and trigger an error instead.

Part-of #5446

Reported-by: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
 src/box/box.cc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/box/box.cc b/src/box/box.cc
index 68579c254..b3cc45358 100644
--- a/src/box/box.cc
+++ b/src/box/box.cc
@@ -609,9 +609,9 @@ box_eval_replication_synchro_quorum(int nr_replicas)
 		return -1;
 	}
 
-	int quorum = -1;
+	int64_t quorum = -1;
 	if (lua_isnumber(tarantool_L, -1))
-		quorum = (int)lua_tonumber(tarantool_L, -1);
+		quorum = luaL_toint64(tarantool_L, -1);
 	lua_pop(tarantool_L, 1);
 
 	/*
@@ -657,7 +657,7 @@ box_check_replication_synchro_quorum(void)
 		return 0;
 	}
 
-	int quorum = cfg_geti("replication_synchro_quorum");
+	int64_t quorum = cfg_geti64("replication_synchro_quorum");
 	if (quorum <= 0 || quorum >= VCLOCK_MAX) {
 		diag_set(ClientError, ER_CFG, "replication_synchro_quorum",
 			 "the value must be greater than zero and less than "
-- 
2.26.2

  parent reply	other threads:[~2020-12-22 11:15 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-22 11:14 [Tarantool-patches] [PATCH v6 0/5] qsync: evaluate replication_synchro_quorum dynamically Cyrill Gorcunov
2020-12-22 11:14 ` [Tarantool-patches] [PATCH v6 1/5] cfg: add cfg_isnumber helper Cyrill Gorcunov
2020-12-22 11:14 ` [Tarantool-patches] [PATCH v6 2/5] cfg: rework box_check_replication_synchro_quorum Cyrill Gorcunov
2020-12-22 11:14 ` [Tarantool-patches] [PATCH v6 3/5] cfg: support symbolic evaluation of replication_synchro_quorum Cyrill Gorcunov
2020-12-22 11:14 ` Cyrill Gorcunov [this message]
2020-12-22 11:14 ` [Tarantool-patches] [PATCH v6 5/5] test: add replication/gh-5446-qsync-eval-quorum.test.lua Cyrill Gorcunov
2020-12-22 13:49 ` [Tarantool-patches] [PATCH v6 0/5] qsync: evaluate replication_synchro_quorum dynamically Vladislav Shpilevoy
2020-12-22 13:53   ` Cyrill Gorcunov
2020-12-22 14:32   ` Cyrill Gorcunov
2020-12-22 17:13   ` Cyrill Gorcunov
2020-12-23 14:14     ` Vladislav Shpilevoy
2020-12-23 15:54       ` Cyrill Gorcunov
2020-12-23 17:52 ` Vladislav Shpilevoy
2020-12-24 13:55   ` Vladislav Shpilevoy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201222111408.48368-5-gorcunov@gmail.com \
    --to=gorcunov@gmail.com \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v6 4/5] cfg: more precise check for replication_synchro_quorum value' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox