summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSunny Kumar <sunkumar@redhat.com>2018-09-26 02:58:10 +0530
committerAmar Tumballi <amarts@redhat.com>2018-10-01 08:01:37 +0000
commit1c0facf59a85b1256a52e7a99b30743283a4c9cf (patch)
tree31789a1edf9bd9c7799f71c6c47ad0228c7f2969
parent1f2aa9acb78f6d004c0ea36f9827087484871344 (diff)
index : fix coverity issues in index.c
This patch fixes CID 1356508 and 1356577. Change-Id: I09bc5398fbf6ee49fc066b42aaedf1170df39df8 updates: bz#789278 Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
-rw-r--r--xlators/features/index/src/index.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/xlators/features/index/src/index.c b/xlators/features/index/src/index.c
index 08785f21a2a..8e850a7151b 100644
--- a/xlators/features/index/src/index.c
+++ b/xlators/features/index/src/index.c
@@ -1503,6 +1503,8 @@ index_save_pargfid_for_entry_changes(xlator_t *this, loc_t *loc, char *path)
int ret = 0;
priv = this->private;
+ if (!loc)
+ return -1;
if (gf_uuid_compare(loc->pargfid, priv->internal_vgfid[ENTRY_CHANGES]))
return 0;
@@ -1558,8 +1560,15 @@ index_lookup_wrapper(call_frame_t *frame, xlator_t *this, loc_t *loc,
op_errno = -ret;
goto done;
}
- strcat(path, "/");
- strcat(path, (char *)loc->name);
+ ret = snprintf(path + strlen(path), PATH_MAX - strlen(path), "/%s",
+ loc->name);
+
+ if ((ret < 0) || (ret > (PATH_MAX - strlen(path)))) {
+ op_errno = EINVAL;
+ op_ret = -1;
+ goto done;
+ }
+
} else if (index_is_virtual_gfid(priv, loc->gfid)) {
subdir = index_get_subdir_from_vgfid(priv, loc->gfid);
make_index_dir_path(priv->index_basepath, subdir, path, sizeof(path));
@@ -1626,8 +1635,8 @@ index_lookup_wrapper(call_frame_t *frame, xlator_t *this, loc_t *loc,
stbuf.ia_ino = -1;
op_ret = 0;
done:
- STACK_UNWIND_STRICT(lookup, frame, op_ret, op_errno, loc->inode, &stbuf,
- xattr, &postparent);
+ STACK_UNWIND_STRICT(lookup, frame, op_ret, op_errno,
+ loc ? loc->inode : NULL, &stbuf, xattr, &postparent);
if (xattr)
dict_unref(xattr);
loc_wipe(&iloc);