Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 7 May 2017 21:22:47 +0000 (UTC)
From:      Rick Macklem <rmacklem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r317924 - stable/11/sys/fs/nfsclient
Message-ID:  <201705072122.v47LMlA4050535@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rmacklem
Date: Sun May  7 21:22:47 2017
New Revision: 317924
URL: https://svnweb.freebsd.org/changeset/base/317924

Log:
  MFC: r317272
  Add checks for failed operations to the NFSv4 client function nfscl_mtofh().
  
  The nfscl_mtofh() function didn't check for failed operations and, as such,
  would have returned EBADRPC for these cases, due to parsing failure.
  This patch adds checks, so that it returns with ND_NOMOREDATA set.
  This is needed for future use in the pNFS server and acts as a safety
  belt in the meantime.

Modified:
  stable/11/sys/fs/nfsclient/nfs_clcomsubs.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/fs/nfsclient/nfs_clcomsubs.c
==============================================================================
--- stable/11/sys/fs/nfsclient/nfs_clcomsubs.c	Sun May  7 21:11:28 2017	(r317923)
+++ stable/11/sys/fs/nfsclient/nfs_clcomsubs.c	Sun May  7 21:22:47 2017	(r317924)
@@ -471,6 +471,11 @@ nfscl_mtofh(struct nfsrv_descript *nd, s
 		flag = fxdr_unsigned(int, *tl);
 	} else if (nd->nd_flag & ND_NFSV4) {
 		NFSM_DISSECT(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
+		/* If the GetFH failed, clear flag. */
+		if (*++tl != 0) {
+			nd->nd_flag |= ND_NOMOREDATA;
+			flag = 0;
+		}
 	}
 	if (flag) {
 		error = nfsm_getfh(nd, nfhpp);
@@ -481,8 +486,12 @@ nfscl_mtofh(struct nfsrv_descript *nd, s
 	/*
 	 * Now, get the attributes.
 	 */
-	if (nd->nd_flag & ND_NFSV4) {
+	if (flag != 0 && (nd->nd_flag & ND_NFSV4) != 0) {
 		NFSM_DISSECT(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
+		if (*++tl != 0) {
+			nd->nd_flag |= ND_NOMOREDATA;
+			flag = 0;
+		}
 	} else if (nd->nd_flag & ND_NFSV3) {
 		NFSM_DISSECT(tl, u_int32_t *, NFSX_UNSIGNED);
 		if (flag) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201705072122.v47LMlA4050535>