From: Cyrill Gorcunov <gorcunov@gmail.com>
To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>,
Serge Petrenko <sergepetrenko@tarantool.org>
Cc: tml <tarantool-patches@dev.tarantool.org>
Subject: [Tarantool-patches] [PATCH 1/2] raft: raft_request_to_string -- don't hardcode size
Date: Wed, 14 Oct 2020 17:26:16 +0300 [thread overview]
Message-ID: <20201014142617.235813-2-gorcunov@gmail.com> (raw)
In-Reply-To: <20201014142617.235813-1-gorcunov@gmail.com>
The size should be matched to the real size of a buffer,
otherwise it is a room for mistake.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
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
next prev parent reply other threads:[~2020-10-14 14:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-14 14:26 [Tarantool-patches] [PATCH 0/2] raft: a few fixes Cyrill Gorcunov
2020-10-14 14:26 ` Cyrill Gorcunov [this message]
2020-10-14 14:26 ` [Tarantool-patches] [PATCH 2/2] raft: decode even invalid states of raft Cyrill Gorcunov
2020-10-15 9:43 ` Serge Petrenko
2020-10-15 9:46 ` Cyrill Gorcunov
2020-10-27 22:18 ` Vladislav Shpilevoy
2020-10-27 22:36 ` Cyrill Gorcunov
2020-10-15 8:44 ` [Tarantool-patches] [PATCH 0/2] raft: a few fixes Cyrill Gorcunov
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=20201014142617.235813-2-gorcunov@gmail.com \
--to=gorcunov@gmail.com \
--cc=sergepetrenko@tarantool.org \
--cc=tarantool-patches@dev.tarantool.org \
--cc=v.shpilevoy@tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH 1/2] raft: raft_request_to_string -- don'\''t hardcode size' \
/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