diff options
author | Kaleb S KEITHLEY <kkeithle@redhat.com> | 2016-06-16 11:29:40 -0400 |
---|---|---|
committer | Kaleb KEITHLEY <kkeithle@redhat.com> | 2016-06-17 02:30:55 -0700 |
commit | 1d42e5e2312a8de45d9c83350f3e3260afba03ae (patch) | |
tree | 1abb194207d8d155dbf1a3b0934773c22f81cde9 /xlators | |
parent | 457ece66327451decd89281d2808f2aa8ba94b60 (diff) |
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.
mainline
> BUG: 1347354
> http://review.gluster.org/14745
Change-Id: I52ac41e1172d0c1e5695a91b9f731cc9e7de4db4
BUG: 1347355
Signed-off-by: Kaleb S KEITHLEY <kkeithle@redhat.com>
Reviewed-on: http://review.gluster.org/14746
Smoke: Gluster Build System <jenkins@build.gluster.org>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Avra Sengupta <asengupt@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-geo-rep.c | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c index 0120404a2ee..2503bded1fe 100644 --- a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c +++ b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c @@ -2964,8 +2964,7 @@ glusterd_op_stage_gsync_create (dict_t *dict, char **op_errstr) struct slave_vol_config slave1 = {{0},}; int type = 0; char monitor_status[NAME_MAX] = {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; @@ -3261,26 +3260,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.", |