|
|
12a457 |
From d2e9eadb81b2f679c3b1d518e5c67c242e7f7695 Mon Sep 17 00:00:00 2001
|
|
|
12a457 |
From: Gaurav Kumar Garg <garg.gaurav52@gmail.com>
|
|
|
12a457 |
Date: Tue, 13 Oct 2015 14:40:55 +0530
|
|
|
12a457 |
Subject: [PATCH 06/26] libglusterfs: pass buffer size to gf_store_read_and_tokenize function
|
|
|
12a457 |
|
|
|
12a457 |
This patch is backport of: http://review.gluster.org/12346
|
|
|
12a457 |
|
|
|
12a457 |
Previously if user set an option where length of key=value goes beyond
|
|
|
12a457 |
PATH_MAX (4096) character then tokenzing the option at the time of
|
|
|
12a457 |
reading configuration file will fail.
|
|
|
12a457 |
This is because of the we was having restraction in fgets to read maximum
|
|
|
12a457 |
of PATH_MAX (4096) length of character.
|
|
|
12a457 |
Consequence of this is when user try to restart glusterd, after setting
|
|
|
12a457 |
key=value length beyond PATH_MAX (4096) character, glusterd will not restart.
|
|
|
12a457 |
|
|
|
12a457 |
With this fix instead of PATH_MAX, consumer of gf_store_read_and_tokenize
|
|
|
12a457 |
function will decide the size of the buffer length.
|
|
|
12a457 |
|
|
|
12a457 |
Change-Id: I655a8ce982effdfff8f3e785ea31f543dbe39301
|
|
|
12a457 |
BUG: 1319670
|
|
|
12a457 |
|
|
|
12a457 |
>> Change-Id: I655a8ce982effdfff8f3e785ea31f543dbe39301
|
|
|
12a457 |
>> BUG: 1271150
|
|
|
12a457 |
>> Signed-off-by: Gaurav Kumar Garg <ggarg@redhat.com>
|
|
|
12a457 |
>> Reviewed-on: http://review.gluster.org/12346
|
|
|
12a457 |
>> Tested-by: NetBSD Build System <jenkins@build.gluster.org>
|
|
|
12a457 |
>> Tested-by: Gluster Build System <jenkins@build.gluster.com>
|
|
|
12a457 |
>> Reviewed-by: Anand Nekkunti <anekkunt@redhat.com>
|
|
|
12a457 |
>> Reviewed-by: Niels de Vos <ndevos@redhat.com>
|
|
|
12a457 |
|
|
|
12a457 |
Signed-off-by: Gaurav Kumar Garg <ggarg@redhat.com>
|
|
|
12a457 |
Change-Id: Iede6502f04210d430a9fc054d63e06c4b4ca78d1
|
|
|
12a457 |
Reviewed-on: https://code.engineering.redhat.com/gerrit/70324
|
|
|
12a457 |
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
12a457 |
Tested-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
12a457 |
---
|
|
|
12a457 |
libglusterfs/src/store.c | 6 ++++--
|
|
|
12a457 |
libglusterfs/src/store.h | 2 +-
|
|
|
12a457 |
xlators/mgmt/glusterd/src/glusterd-store.c | 2 +-
|
|
|
12a457 |
3 files changed, 6 insertions(+), 4 deletions(-)
|
|
|
12a457 |
|
|
|
12a457 |
diff --git a/libglusterfs/src/store.c b/libglusterfs/src/store.c
|
|
|
12a457 |
index 3da82a4..53b44b1 100644
|
|
|
12a457 |
--- a/libglusterfs/src/store.c
|
|
|
12a457 |
+++ b/libglusterfs/src/store.c
|
|
|
12a457 |
@@ -181,7 +181,7 @@ out:
|
|
|
12a457 |
}
|
|
|
12a457 |
|
|
|
12a457 |
int
|
|
|
12a457 |
-gf_store_read_and_tokenize (FILE *file, char *str, char **iter_key,
|
|
|
12a457 |
+gf_store_read_and_tokenize (FILE *file, char *str, int size, char **iter_key,
|
|
|
12a457 |
char **iter_val, gf_store_op_errno_t *store_errno)
|
|
|
12a457 |
{
|
|
|
12a457 |
int32_t ret = -1;
|
|
|
12a457 |
@@ -197,7 +197,7 @@ gf_store_read_and_tokenize (FILE *file, char *str, char **iter_key,
|
|
|
12a457 |
GF_ASSERT (iter_val);
|
|
|
12a457 |
GF_ASSERT (store_errno);
|
|
|
12a457 |
|
|
|
12a457 |
- temp = fgets (str, PATH_MAX, file);
|
|
|
12a457 |
+ temp = fgets (str, size, file);
|
|
|
12a457 |
if (temp == NULL || feof (file)) {
|
|
|
12a457 |
ret = -1;
|
|
|
12a457 |
*store_errno = GD_STORE_EOF;
|
|
|
12a457 |
@@ -292,6 +292,7 @@ gf_store_retrieve_value (gf_store_handle_t *handle, char *key, char **value)
|
|
|
12a457 |
|
|
|
12a457 |
do {
|
|
|
12a457 |
ret = gf_store_read_and_tokenize (handle->read, scan_str,
|
|
|
12a457 |
+ st.st_size + 1,
|
|
|
12a457 |
&iter_key, &iter_val,
|
|
|
12a457 |
&store_errno);
|
|
|
12a457 |
if (ret < 0) {
|
|
|
12a457 |
@@ -574,6 +575,7 @@ gf_store_iter_get_next (gf_store_iter_t *iter, char **key, char **value,
|
|
|
12a457 |
}
|
|
|
12a457 |
|
|
|
12a457 |
ret = gf_store_read_and_tokenize (iter->file, scan_str,
|
|
|
12a457 |
+ st.st_size + 1,
|
|
|
12a457 |
&iter_key, &iter_val,
|
|
|
12a457 |
&store_errno);
|
|
|
12a457 |
if (ret < 0) {
|
|
|
12a457 |
diff --git a/libglusterfs/src/store.h b/libglusterfs/src/store.h
|
|
|
12a457 |
index 6b7c98a..44af117 100644
|
|
|
12a457 |
--- a/libglusterfs/src/store.h
|
|
|
12a457 |
+++ b/libglusterfs/src/store.h
|
|
|
12a457 |
@@ -64,7 +64,7 @@ int32_t
|
|
|
12a457 |
gf_store_unlink_tmppath (gf_store_handle_t *shandle);
|
|
|
12a457 |
|
|
|
12a457 |
int
|
|
|
12a457 |
-gf_store_read_and_tokenize (FILE *file, char *str, char **iter_key,
|
|
|
12a457 |
+gf_store_read_and_tokenize (FILE *file, char *str, int size, char **iter_key,
|
|
|
12a457 |
char **iter_val, gf_store_op_errno_t *store_errno);
|
|
|
12a457 |
|
|
|
12a457 |
int32_t
|
|
|
12a457 |
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
|
|
|
12a457 |
index 4be1317..61af29a 100644
|
|
|
12a457 |
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
|
|
|
12a457 |
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
|
|
|
12a457 |
@@ -3528,7 +3528,7 @@ glusterd_store_retrieve_missed_snaps_list (xlator_t *this)
|
|
|
12a457 |
}
|
|
|
12a457 |
|
|
|
12a457 |
do {
|
|
|
12a457 |
- ret = gf_store_read_and_tokenize (fp, buf,
|
|
|
12a457 |
+ ret = gf_store_read_and_tokenize (fp, buf, sizeof (buf),
|
|
|
12a457 |
&missed_node_info, &value,
|
|
|
12a457 |
&store_errno);
|
|
|
12a457 |
if (ret) {
|
|
|
12a457 |
--
|
|
|
12a457 |
1.7.1
|
|
|
12a457 |
|