summaryrefslogtreecommitdiffstats
path: root/xlators/features/changelog/lib/src/gf-changelog-journal-handler.c
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2015-03-31 09:50:44 +0200
committerVenky Shankar <vshankar@redhat.com>2015-04-08 08:48:27 +0000
commit2a224653df93c4b3a6b3914509f314196ad61008 (patch)
treef50b9777ca91cfd50155a4b03766f6e5cf3e4b70 /xlators/features/changelog/lib/src/gf-changelog-journal-handler.c
parentc262430726635ce868558f299ad494734a173774 (diff)
features/changelog: fix possible illegal memory access (CID 1288819)
Coverity CID 1288819 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: Ie2d2970f37840146aa18724be3b89e93194c8160 BUG: 789278 Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-on: http://review.gluster.org/10062 Reviewed-by: Niels de Vos <ndevos@redhat.com> Reviewed-by: Venky Shankar <vshankar@redhat.com> Tested-by: Venky Shankar <vshankar@redhat.com>
Diffstat (limited to 'xlators/features/changelog/lib/src/gf-changelog-journal-handler.c')
-rw-r--r--xlators/features/changelog/lib/src/gf-changelog-journal-handler.c3
1 files changed, 2 insertions, 1 deletions
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 538a7faff68..c4e14708b5f 100644
--- a/xlators/features/changelog/lib/src/gf-changelog-journal-handler.c
+++ b/xlators/features/changelog/lib/src/gf-changelog-journal-handler.c
@@ -947,7 +947,8 @@ gf_changelog_journal_init (void *xl, struct gf_brick_spec *brick)
goto dealloc_private;
}
- (void) strncpy (jnl->jnl_brickpath, brick->brick_path, PATH_MAX);
+ (void) strncpy (jnl->jnl_brickpath, brick->brick_path, PATH_MAX-1);
+ jnl->jnl_brickpath[PATH_MAX-1] = 0;
/* RFC 3986 {de,en}coding */
for (i = 0; i < 256; i++) {