From 804de0be6f100ede12f6131d3320cf06a227f191 Mon Sep 17 00:00:00 2001 From: David Spisla Date: Wed, 19 Jun 2019 13:07:56 +0200 Subject: 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 --- xlators/features/read-only/src/worm.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'xlators/features') 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) { -- cgit