features/changelog: fix possible memory illegal access (2 of 2, coverity)

Coverity CID 1288822 (#2 of 2)

strncpy executed with a limit equal to the target array
size potentially leaves the target string not null terminated.
Make sure the copied string is a valid 0 terminated string.

Change-Id: If283dd6f716912f65729edf6ea26a4331a697151
BUG: 789278
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-on: http://review.gluster.org/10059
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Poornima G <pgurusid@redhat.com>
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Reviewed-by: Venky Shankar <vshankar@redhat.com>
Tested-by: Venky Shankar <vshankar@redhat.com>
This commit is contained in:
Michael Adam 2015-03-31 02:36:30 +02:00 committed by Venky Shankar
parent 4b18fba406
commit dc26a253f5

View File

@ -876,7 +876,8 @@ gf_changelog_init_history (xlator_t *this,
goto dealloc_hist;
}
(void) strncpy (jnl->hist_jnl->jnl_brickpath, brick_path, PATH_MAX);
(void) strncpy (jnl->hist_jnl->jnl_brickpath, brick_path, PATH_MAX-1);
jnl->hist_jnl->jnl_brickpath[PATH_MAX-1] = 0;
for (i = 0; i < 256; i++) {
jnl->hist_jnl->rfc3986[i] =