From 4a15ea1fd36390fa247dc2e429f14dc8fd621c49 Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Wed, 2 Jan 2019 18:42:19 +0530 Subject: rpcsvc: Don't expect dictionary values to be available When reconfigure happens, string values from one dictionary are directly set in another dictionary. This can lead to invalid memory when the first dictionary is freed up. So do dict_set_dynstr_with_alloc instead of dict_set_str updates bz#1650403 Change-Id: Id53236467521cfdeb07e7178d87ba6cf88d17003 Signed-off-by: Pranith Kumar K --- rpc/rpc-lib/src/rpcsvc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'rpc/rpc-lib/src') diff --git a/rpc/rpc-lib/src/rpcsvc.c b/rpc/rpc-lib/src/rpcsvc.c index c057b6f3cb9..74373c44f91 100644 --- a/rpc/rpc-lib/src/rpcsvc.c +++ b/rpc/rpc-lib/src/rpcsvc.c @@ -2563,7 +2563,7 @@ rpcsvc_reconfigure_options(rpcsvc_t *svc, dict_t *options) */ dict_del(svc->options, srchkey); if (!dict_get_str(options, srchkey, &keyval)) { - ret = dict_set_str(svc->options, srchkey, keyval); + ret = dict_set_dynstr_with_alloc(svc->options, srchkey, keyval); if (ret < 0) { gf_log(GF_RPCSVC, GF_LOG_ERROR, "dict_set_str error"); GF_FREE(srchkey); @@ -2595,7 +2595,7 @@ rpcsvc_reconfigure_options(rpcsvc_t *svc, dict_t *options) */ dict_del(svc->options, srchkey); if (!dict_get_str(options, srchkey, &keyval)) { - ret = dict_set_str(svc->options, srchkey, keyval); + ret = dict_set_dynstr_with_alloc(svc->options, srchkey, keyval); if (ret < 0) { gf_log(GF_RPCSVC, GF_LOG_ERROR, "dict_set_str error"); GF_FREE(srchkey); -- cgit