summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMohit Agrawal <moagrawa@redhat.com>2020-08-01 09:28:47 +0530
committerSanju Rakonde <sanjurakonde@review.gluster.org>2020-08-04 12:41:32 +0000
commit6e8e73a06d71382f8f6e3cd83fe72692d19e66ba (patch)
treedba92062d7f61ec0242d44ce7136c28043f8eeb2
parente5c13c573477f2e5666013decf7e50934c0f55cb (diff)
glusterd: Increase buffer length to save multiple hostnames in peer file
Problem: At the time of handling friend update request glusterd updates peer file and if DNS has returned multiple hostnames for the same IP, glusterd saves all hostnames in peer file.In commit 1fa089e7a2b180e0bdcc1e7e09a63934a2a0c0ef We changed the approach to save all key value pairs in single shot. In case of a buffer is not having space to store the hostnames glusterd writes partial hostname in peer file. Solution: To avoid the failure increase the buffer length Change-Id: Iee969d165333e9c5ba69431d474c541b8f12d442 Fixes: #1407 Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
index ccc0223ba30..465e41ef00b 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
@@ -4403,7 +4403,7 @@ glusterd_store_create_peer_shandle(glusterd_peerinfo_t *peerinfo)
static int32_t
glusterd_store_peer_write(int fd, glusterd_peerinfo_t *peerinfo)
{
- char buf[128];
+ char buf[PATH_MAX];
uint total_len = 0;
int32_t ret = 0;
int32_t i = 1;
@@ -4412,7 +4412,7 @@ glusterd_store_peer_write(int fd, glusterd_peerinfo_t *peerinfo)
ret = snprintf(buf + total_len, sizeof(buf) - total_len, "%s=%s\n%s=%d\n",
GLUSTERD_STORE_KEY_PEER_UUID, uuid_utoa(peerinfo->uuid),
GLUSTERD_STORE_KEY_PEER_STATE, peerinfo->state.state);
- if (ret < 0 || ret >= sizeof(buf)) {
+ if (ret < 0 || ret >= sizeof(buf) - total_len) {
ret = -1;
goto out;
}
@@ -4423,7 +4423,7 @@ glusterd_store_peer_write(int fd, glusterd_peerinfo_t *peerinfo)
ret = snprintf(buf + total_len, sizeof(buf) - total_len,
GLUSTERD_STORE_KEY_PEER_HOSTNAME "%d=%s\n", i,
hostname->hostname);
- if (ret < 0 || ret >= sizeof(buf)) {
+ if (ret < 0 || ret >= sizeof(buf) - total_len) {
ret = -1;
goto out;
}