From ae4a410cb411c3f1b5ebac9d49d47e2fc00c9a74 Mon Sep 17 00:00:00 2001 From: Kaleb S KEITHLEY Date: Thu, 16 Jun 2016 11:24:30 -0400 Subject: glusterd: unsafe strcat, strncat use in glusterd_op_stage_gsync_create() SuSE build system post-compile analysis aborts pkg build due to unsafe strcat, strncat usage. Change-Id: I52ac41e1172d0c1e5695a91b9f731cc9e7de4db4 BUG: 1347354 Signed-off-by: Kaleb S KEITHLEY Reviewed-on: http://review.gluster.org/14745 Smoke: Gluster Build System CentOS-regression: Gluster Build System NetBSD-regression: NetBSD Build System Reviewed-by: Jeff Darcy --- xlators/mgmt/glusterd/src/glusterd-geo-rep.c | 32 +++++++++++----------------- 1 file changed, 13 insertions(+), 19 deletions(-) (limited to 'xlators/mgmt/glusterd/src/glusterd-geo-rep.c') diff --git a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c index 04f2f14af0c..13407c22df9 100644 --- a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c +++ b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c @@ -2961,8 +2961,7 @@ glusterd_op_stage_gsync_create (dict_t *dict, char **op_errstr) char *georep_session_wrkng_dir = NULL; struct slave_vol_config slave1 = {{0},}; int type = 0; - char old_slave_url_info[SLAVE_URL_INFO_MAX] = {0}; - char *old_slave_url = NULL; + char old_slave_url[SLAVE_URL_INFO_MAX] = {0}; char old_confpath[PATH_MAX] = {0}; gf_boolean_t is_running = _gf_false; int ret_status = 0; @@ -3258,26 +3257,21 @@ glusterd_op_stage_gsync_create (dict_t *dict, char **op_errstr) /* Do the check, only if different slave host/slave user */ if (is_different_slavehost || is_different_username) { - ret = snprintf (old_confpath, sizeof(old_confpath) - 1, - "%s/"GEOREP"/%s_%s_%s/gsyncd.conf", - conf->workdir, volinfo->volname, - slave1.old_slvhost, slave_vol); + (void) snprintf (old_confpath, sizeof(old_confpath) - 1, + "%s/"GEOREP"/%s_%s_%s/gsyncd.conf", + conf->workdir, volinfo->volname, + slave1.old_slvhost, slave_vol); /* construct old slave url with (old) slave host */ - old_slave_url = old_slave_url_info; - strncpy (old_slave_url, slave1.old_slvhost, - sizeof(old_slave_url_info)); - old_slave_url = strcat (old_slave_url, "::"); - old_slave_url = strncat (old_slave_url, slave_vol, - sizeof(old_slave_url_info)); - - ret = glusterd_check_gsync_running_local ( - volinfo->volname, - old_slave_url, - old_confpath, - &is_running); + (void) snprintf (old_slave_url, + sizeof(old_slave_url) - 1, + "%s::%s", slave1.old_slvhost, + slave_vol); + + ret = glusterd_check_gsync_running_local (volinfo->volname, + old_slave_url, old_confpath, &is_running); if (_gf_true == is_running) { - snprintf (errmsg, sizeof(errmsg), "Geo" + (void) snprintf (errmsg, sizeof(errmsg), "Geo" "-replication session between %s and %s" " is still active. Please stop the " "session and retry.", -- cgit