From dc26a253f5f393745bd435721e31d6e2e598eed1 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 31 Mar 2015 02:36:30 +0200 Subject: 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 Reviewed-on: http://review.gluster.org/10059 Tested-by: Gluster Build System Reviewed-by: Poornima G Reviewed-by: Kaleb KEITHLEY Reviewed-by: Venky Shankar Tested-by: Venky Shankar --- xlators/features/changelog/lib/src/gf-changelog-journal-handler.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'xlators/features/changelog') diff --git a/xlators/features/changelog/lib/src/gf-changelog-journal-handler.c b/xlators/features/changelog/lib/src/gf-changelog-journal-handler.c index 6ee6f9f074f..3cb0eef7ba6 100644 --- a/xlators/features/changelog/lib/src/gf-changelog-journal-handler.c +++ b/xlators/features/changelog/lib/src/gf-changelog-journal-handler.c @@ -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] = -- cgit