From 3579aaaef0027c62bad57952e433e15fa9f1532c Mon Sep 17 00:00:00 2001 From: Richard Wareing Date: Mon, 22 Sep 2014 17:42:04 -0700 Subject: nfs: Check for null buf, and set op_errno to EIO not 0 Summary: - Prevent crashes for the case where "getattr" actually failed and returned with a NULL buf, but the op_errno was set to 0. - This is a cherry-pick of D1571184 Signed-off-by: Shreyas Siravara Change-Id: Ia2d6ad7539df714f9420dcf063c7c14e727bb7e3 BUG: 1428064 Reviewed-on: http://review.gluster.org/16152 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Kevin Vigor Reviewed-on: https://review.gluster.org/16803 Reviewed-by: Amar Tumballi Tested-by: Jeff Darcy Reviewed-by: Jeff Darcy --- xlators/nfs/server/src/nfs3.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'xlators/nfs/server/src/nfs3.c') diff --git a/xlators/nfs/server/src/nfs3.c b/xlators/nfs/server/src/nfs3.c index 729f811c917..6399d624ff8 100644 --- a/xlators/nfs/server/src/nfs3.c +++ b/xlators/nfs/server/src/nfs3.c @@ -862,6 +862,12 @@ nfs3svc_getattr_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, cs = frame->local; if (op_ret == -1) { + /* Prevent crashes for the case where this call fails + * and buf is left in a NULL state, yet the op_errno == 0. + */ + if (!buf && op_errno == 0) { + op_errno = EIO; + } status = nfs3_cbk_errno_status (op_ret, op_errno); } -- cgit