summaryrefslogtreecommitdiffstats
path: root/xlators/features
diff options
context:
space:
mode:
authorDavid Spisla <david.spisla@iternity.com>2019-06-19 13:07:56 +0200
committerAmar Tumballi <amarts@redhat.com>2019-06-21 04:19:11 +0000
commit804de0be6f100ede12f6131d3320cf06a227f191 (patch)
tree037ab211ef63d76d9b99720abaef1cfd1976e7f6 /xlators/features
parent52cf03ee314e46aa990c5b813d83019aabb04d58 (diff)
WORM-Xlator: Avoid performing fsetxattr if fd is NULL
If worm_create_cbk receives an error (op_ret == -1) fd will be NULL and therefore performing fsetxattr would lead to a segfault and the brick process crashes. To avoid this we allow setting fsetxattr only if op_ret >= 0 . If an error happens we explicitly unwind Change-Id: Ie7f8a198add93e5cd908eb7029cffc834c3b58a6 fixes: bz#1717757 Signed-off-by: David Spisla <david.spisla@iternity.com>
Diffstat (limited to 'xlators/features')
-rw-r--r--xlators/features/read-only/src/worm.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/xlators/features/read-only/src/worm.c b/xlators/features/read-only/src/worm.c
index cc3d15b8b2a..f59663802e6 100644
--- a/xlators/features/read-only/src/worm.c
+++ b/xlators/features/read-only/src/worm.c
@@ -429,6 +429,13 @@ worm_create_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
read_only_priv_t *priv = NULL;
dict_t *dict = NULL;
+ // In case of an error exit because fd can be NULL and this would
+ // cause an segfault when performing fsetxattr . We explicitly
+ // unwind to avoid future problems
+ if (op_ret < 0) {
+ goto out;
+ }
+
priv = this->private;
GF_ASSERT(priv);
if (priv->worm_file) {