From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-f193.google.com (mail-lj1-f193.google.com [209.85.208.193]) (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 7FE5D446439 for ; Wed, 14 Oct 2020 17:26:34 +0300 (MSK) Received: by mail-lj1-f193.google.com with SMTP id m20so3424993ljj.5 for ; Wed, 14 Oct 2020 07:26:34 -0700 (PDT) From: Cyrill Gorcunov Date: Wed, 14 Oct 2020 17:26:16 +0300 Message-Id: <20201014142617.235813-2-gorcunov@gmail.com> In-Reply-To: <20201014142617.235813-1-gorcunov@gmail.com> References: <20201014142617.235813-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 1/2] raft: raft_request_to_string -- don't hardcode size List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Vladislav Shpilevoy , Serge Petrenko Cc: tml The size should be matched to the real size of a buffer, otherwise it is a room for mistake. Signed-off-by: Cyrill Gorcunov --- src/box/raft.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/box/raft.c b/src/box/raft.c index 0b6c373e8..9de77b0ec 100644 --- a/src/box/raft.c +++ b/src/box/raft.c @@ -268,8 +268,8 @@ static const char * raft_request_to_string(const struct raft_request *req) { assert(req->term != 0); - int size = 1024; char buf[1024]; + int size = sizeof(buf); char *pos = buf; int rc = snprintf(pos, size, "{term: %llu", (unsigned long long)req->term); -- 2.26.2