summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSubha sree Mohankumar <smohanku@redhat.com>2017-09-25 01:03:09 +0530
committerAmar Tumballi <amarts@redhat.com>2017-10-31 07:56:24 +0000
commit1d92d5173b1c9e5cda60fe5c5a237fc4b82df030 (patch)
treeaaa7dcfb4b652ddee9b779c2afdf7a192d6b6069
parentf4805ca6cf67d1d8394b14f21eceb2d9592ba228 (diff)
Xlators/features: Coverity Issue "NEGATIVE_RETURNS" in worm_truncate,worm_ftruncate,worm_link,worn_unlink and worm_rename.
Issue :Event negative_returns: "op_errno" is passed to a parameter that cannot be negative. Fix : In functions worm_link,worm_unlink,worm_truncate,worm_ftruncate and worm_rename, added an condition to check the whether value of "op_errno" is negative or not.If the value is negative, then it is set to EROFS. Change-Id: Ie65601b6cc9799f587cc574408281dab50a58afb BUG: 789278 Signed-off-by: Subha sree Mohankumar <smohanku@redhat.com>
-rw-r--r--xlators/features/read-only/src/worm.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/xlators/features/read-only/src/worm.c b/xlators/features/read-only/src/worm.c
index 9d034a5cf4c..a1474b6bc27 100644
--- a/xlators/features/read-only/src/worm.c
+++ b/xlators/features/read-only/src/worm.c
@@ -71,9 +71,12 @@ worm_link (call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc,
GF_FOP_LINK);
out:
- if (op_errno)
+ if (op_errno) {
+ if (op_errno < 0)
+ op_errno = EROFS;
STACK_UNWIND_STRICT (link, frame, -1, op_errno, NULL, NULL,
NULL, NULL, NULL);
+ }
else
STACK_WIND_TAIL (frame, FIRST_CHILD(this),
FIRST_CHILD(this)->fops->link,
@@ -107,9 +110,12 @@ worm_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
op_errno = gf_worm_state_transition (this, _gf_false, loc,
GF_FOP_UNLINK);
out:
- if (op_errno)
+ if (op_errno) {
+ if (op_errno < 0)
+ op_errno = EROFS;
STACK_UNWIND_STRICT (unlink, frame, -1, op_errno, NULL, NULL,
NULL);
+ }
else
STACK_WIND_TAIL (frame, FIRST_CHILD(this),
FIRST_CHILD(this)->fops->unlink,
@@ -157,9 +163,12 @@ check_newloc:
}
out:
- if (op_errno)
+ if (op_errno) {
+ if (op_errno < 0)
+ op_errno = EROFS;
STACK_UNWIND_STRICT (rename, frame, -1, op_errno, NULL,
NULL, NULL, NULL, NULL, NULL);
+ }
else
STACK_WIND_TAIL (frame, FIRST_CHILD (this),
FIRST_CHILD (this)->fops->rename,
@@ -192,9 +201,12 @@ worm_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset,
GF_FOP_TRUNCATE);
out:
- if (op_errno)
+ if (op_errno) {
+ if (op_errno < 0)
+ op_errno = EROFS;
STACK_UNWIND_STRICT (truncate, frame, -1, op_errno, NULL, NULL,
NULL);
+ }
else
STACK_WIND_TAIL (frame, FIRST_CHILD (this),
FIRST_CHILD (this)->fops->truncate,
@@ -227,9 +239,12 @@ worm_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
GF_FOP_FTRUNCATE);
out:
- if (op_errno)
+ if (op_errno) {
+ if (op_errno < 0)
+ op_errno = EROFS;
STACK_UNWIND_STRICT (ftruncate, frame, -1, op_errno, NULL, NULL,
NULL);
+ }
else
STACK_WIND_TAIL (frame, FIRST_CHILD (this),
FIRST_CHILD (this)->fops->ftruncate,