summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authorGaurav Kumar Garg <garg.gaurav52@gmail.com>2015-10-13 14:40:55 +0530
committerNiels de Vos <ndevos@redhat.com>2016-03-23 13:41:28 -0700
commit12861b75dcc2319067cabc903e688b4ceb4763fe (patch)
treea2bc27425c28820af56f3781e65371674ead29af /libglusterfs
parent8f5323882d90e3dd4ab855c79737e6d2302fc739 (diff)
libglusterfs: pass buffer size to gf_store_read_and_tokenize function
This patch is backport of: http://review.gluster.org/#/c/12346/ Previously if user set an option where length of key=value goes beyond PATH_MAX (4096) character then tokenzing the option at the time of reading configuration file will fail. This is because of the we was having restraction in fgets to read maximum of PATH_MAX (4096) length of character. Consequence of this is when user try to restart glusterd, after setting key=value length beyond PATH_MAX (4096) character, glusterd will not restart. With this fix instead of PATH_MAX, consumer of gf_store_read_and_tokenize function will decide the size of the buffer length. Cherry picked from commit 816ca94f5dd49f34f395caf501de3c71f0ba113d: >> Change-Id: I655a8ce982effdfff8f3e785ea31f543dbe39301 >> BUG: 1271150 >> Signed-off-by: Gaurav Kumar Garg <ggarg@redhat.com> >> Reviewed-on: http://review.gluster.org/12346 >> Tested-by: NetBSD Build System <jenkins@build.gluster.org> >> Tested-by: Gluster Build System <jenkins@build.gluster.com> >> Reviewed-by: Anand Nekkunti <anekkunt@redhat.com> >> Reviewed-by: Niels de Vos <ndevos@redhat.com> Change-Id: I5b76e81a4ad31a286fb4298ba27f3230fba99ab4 BUG: 1319649 Signed-off-by: Gaurav Kumar Garg <ggarg@redhat.com> Reviewed-on: http://review.gluster.org/13795 NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Niels de Vos <ndevos@redhat.com> Smoke: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/store.c6
-rw-r--r--libglusterfs/src/store.h2
2 files changed, 5 insertions, 3 deletions
diff --git a/libglusterfs/src/store.c b/libglusterfs/src/store.c
index 3da82a4768d..53b44b1e1c8 100644
--- a/libglusterfs/src/store.c
+++ b/libglusterfs/src/store.c
@@ -181,7 +181,7 @@ out:
}
int
-gf_store_read_and_tokenize (FILE *file, char *str, char **iter_key,
+gf_store_read_and_tokenize (FILE *file, char *str, int size, char **iter_key,
char **iter_val, gf_store_op_errno_t *store_errno)
{
int32_t ret = -1;
@@ -197,7 +197,7 @@ gf_store_read_and_tokenize (FILE *file, char *str, char **iter_key,
GF_ASSERT (iter_val);
GF_ASSERT (store_errno);
- temp = fgets (str, PATH_MAX, file);
+ temp = fgets (str, size, file);
if (temp == NULL || feof (file)) {
ret = -1;
*store_errno = GD_STORE_EOF;
@@ -292,6 +292,7 @@ gf_store_retrieve_value (gf_store_handle_t *handle, char *key, char **value)
do {
ret = gf_store_read_and_tokenize (handle->read, scan_str,
+ st.st_size + 1,
&iter_key, &iter_val,
&store_errno);
if (ret < 0) {
@@ -574,6 +575,7 @@ gf_store_iter_get_next (gf_store_iter_t *iter, char **key, char **value,
}
ret = gf_store_read_and_tokenize (iter->file, scan_str,
+ st.st_size + 1,
&iter_key, &iter_val,
&store_errno);
if (ret < 0) {
diff --git a/libglusterfs/src/store.h b/libglusterfs/src/store.h
index 6b7c98a3547..44af117f48c 100644
--- a/libglusterfs/src/store.h
+++ b/libglusterfs/src/store.h
@@ -64,7 +64,7 @@ int32_t
gf_store_unlink_tmppath (gf_store_handle_t *shandle);
int
-gf_store_read_and_tokenize (FILE *file, char *str, char **iter_key,
+gf_store_read_and_tokenize (FILE *file, char *str, int size, char **iter_key,
char **iter_val, gf_store_op_errno_t *store_errno);
int32_t