From 91cb12be96fb543ee9c0b47bfa8792786286aff7 Mon Sep 17 00:00:00 2001 From: Sunny Kumar Date: Tue, 30 Oct 2018 20:22:41 +0530 Subject: posix : fix coverity issues in posix-entry-ops.c This patch fixes CID: 1. 1389762 : Explicit null dereferenced 2. 1390462 : Argument cannot be negative 3. 1124552 : Explicit null dereferenced 4. 1356522 : Argument cannot be negative updates: bz#789278 Change-Id: I1262f3b4b61a6e65bb34884f46df9a24b8dd03f1 Signed-off-by: Sunny Kumar --- xlators/storage/posix/src/posix-entry-ops.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'xlators/storage/posix') diff --git a/xlators/storage/posix/src/posix-entry-ops.c b/xlators/storage/posix/src/posix-entry-ops.c index 1888de7db9b..ca5b8b1d4bf 100644 --- a/xlators/storage/posix/src/posix-entry-ops.c +++ b/xlators/storage/posix/src/posix-entry-ops.c @@ -211,7 +211,11 @@ posix_lookup(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) MAKE_INODE_HANDLE(real_path, this, loc, &buf); } else { MAKE_ENTRY_HANDLE(real_path, par_path, this, loc, &buf); - + if (!real_path || !par_path) { + op_ret = -1; + op_errno = ESTALE; + goto out; + } if (gf_uuid_is_null(loc->inode->gfid)) { op_ret = posix_gfid_heal(this, real_path, loc, xdata); if (op_ret < 0) { @@ -787,6 +791,8 @@ posix_mkdir(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, } op_errno = dict_set_int8(xdata_rsp, GF_PREOP_CHECK_FAILED, 1); + if (op_errno < 0) + op_errno = errno; goto out; } @@ -1223,7 +1229,7 @@ posix_unlink(call_frame_t *frame, xlator_t *this, loc_t *loc, int xflag, unwind_dict = dict_new(); if (!unwind_dict) { - op_errno = -ENOMEM; + op_errno = ENOMEM; op_ret = -1; goto out; } @@ -2255,6 +2261,12 @@ posix_put(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, MAKE_ENTRY_HANDLE(real_path, par_path, this, loc, &stbuf); + if (!real_path || !par_path) { + op_ret = -1; + op_errno = ESTALE; + goto out; + } + op_ret = posix_pstat(this, loc->parent, loc->pargfid, par_path, &preparent, _gf_false); if (op_ret < 0) { -- cgit