summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2015-03-31 02:28:07 +0200
committerVijay Bellur <vbellur@redhat.com>2015-04-02 06:27:51 -0700
commitf4be9bc3c530ab35a0cd1939df8c43abe54e540d (patch)
treea0e8ca2cd15e5a1cb54adf1536504078f4c0956e
parent41bc3f7f023de198c695bdb7708afef3910cc761 (diff)
features/changelog: fix possible illegal mem access (CID 1288822)
Coverity CID 1288822 (#1 of 2) strncpy executed with a limit equal to the target array size potentially leaves the target string not null terminated. In this case the strncpy is not needed due to the snprintf with the same target buffer which follows immediately. This patch also removes the now unneeded scratch_dir argument to gf_changelog_init_history(), which is semantically correct, since scratch_dir has previously been filled into jnl->jnl_working_dir by the caller, and this is now used to fill hist_scratch_dir. Change-Id: Ib1ed3a1058e80e34191758921b49c29030d6c9db BUG: 789278 Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-on: http://review.gluster.org/10058 Reviewed-by: Kotresh HR <khiremat@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
-rw-r--r--xlators/features/changelog/lib/src/gf-changelog-journal-handler.c6
1 files changed, 2 insertions, 4 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 3cb0eef7ba6..65ee9555514 100644
--- a/xlators/features/changelog/lib/src/gf-changelog-journal-handler.c
+++ b/xlators/features/changelog/lib/src/gf-changelog-journal-handler.c
@@ -842,7 +842,7 @@ gf_changelog_open_dirs (xlator_t *this, gf_changelog_journal_t *jnl)
int
gf_changelog_init_history (xlator_t *this,
gf_changelog_journal_t *jnl,
- char *brick_path, char *scratch_dir)
+ char *brick_path)
{
int i = 0;
int ret = 0;
@@ -856,7 +856,6 @@ gf_changelog_init_history (xlator_t *this,
jnl->hist_jnl->jnl_dir = NULL;
jnl->hist_jnl->jnl_fd = -1;
- (void) strncpy (hist_scratch_dir, scratch_dir, PATH_MAX);
(void) snprintf (hist_scratch_dir, PATH_MAX,
"%s/"GF_CHANGELOG_HISTORY_DIR"/",
jnl->jnl_working_dir);
@@ -957,8 +956,7 @@ gf_changelog_journal_init (void *xl, struct gf_brick_spec *brick)
i == '-' || i == '.' || i == '_') ? i : 0;
}
- ret = gf_changelog_init_history (this, jnl,
- brick->brick_path, scratch_dir);
+ ret = gf_changelog_init_history (this, jnl, brick->brick_path);
if (ret)
goto cleanup_fds;