various: fix gcc7isms

Fedora 26 (rawhide) has just updated to gcc7 which is significantly pickier
about several things.

In particular:
 - 9P: add checks to make sure we never overflow our buffers
 - nfs4 recovery: cidstr_len has to be at least 20 bytes long to store
any "%zi" format, even if it won't be that long in practice
 - nfs4 recovery ip_match was just wrong, we were checking if the client
ip matches the server hostname ?!
 - nfs4 exchange id: stop storing cid_server_owner/cid_server_scope in
the client struct, which lets us work around a possible overrun.
 - proxy: only for systems where long isn't 64 bits, need to fill the
verifier differently

Change-Id: Ib56fcfe86b589c74ffb362f65e5e5203177401f1
Signed-off-by: Dominique Martinet <dominique.martinet@cea.fr>
diff --git a/src/FSAL/FSAL_PROXY/handle.c b/src/FSAL/FSAL_PROXY/handle.c
index e85ff26..f54134b 100644
--- a/src/FSAL/FSAL_PROXY/handle.c
+++ b/src/FSAL/FSAL_PROXY/handle.c
@@ -820,6 +820,7 @@
 	nfs_argop4 arg[FSAL_CLIENTID_NB_OP_ALLOC];
 	nfs_resop4 res[FSAL_CLIENTID_NB_OP_ALLOC];
 	nfs_client_id4 nfsclientid;
+	uint64_t temp_verifier;
 	cb_client4 cbproxy;
 	char clientid_name[MAXNAMLEN + 1];
 	SETCLIENTID4resok *sok;
@@ -838,12 +839,11 @@
 		 getpid());
 	nfsclientid.id.id_len = strlen(clientid_name);
 	nfsclientid.id.id_val = clientid_name;
-	if (sizeof(ServerBootTime.tv_sec) == NFS4_VERIFIER_SIZE)
-		memcpy(&nfsclientid.verifier, &ServerBootTime.tv_sec,
-		       sizeof(nfsclientid.verifier));
-	else
-		snprintf(nfsclientid.verifier, NFS4_VERIFIER_SIZE, "%08x",
-			 (int)ServerBootTime.tv_sec);
+
+	/* copy to intermediate uint64_t to 0-fill or truncate as needed */
+	temp_verifier = (uint64_t)ServerBootTime.tv_sec;
+	BUILD_BUG_ON(sizeof(nfsclientid.verifier) != sizeof(uint64_t));
+	memcpy(&nfsclientid.verifier, &temp_verifier, sizeof(uint64_t));
 
 	cbproxy.cb_program = 0;
 	cbproxy.cb_location.r_netid = "tcp";
diff --git a/src/Protocols/9P/9p_attach.c b/src/Protocols/9P/9p_attach.c
index e131164..5b00b7e 100644
--- a/src/Protocols/9P/9p_attach.c
+++ b/src/Protocols/9P/9p_attach.c
@@ -60,7 +60,7 @@
 	struct _9p_fid *pfid = NULL;
 
 	fsal_status_t fsal_status;
-	char exppath[MAXPATHLEN];
+	char exppath[MAXPATHLEN+1];
 	struct gsh_buffdesc fh_desc;
 	struct fsal_obj_handle *pfsal_handle;
 	int port;
@@ -88,7 +88,11 @@
 	 *
 	 * Keep it in the op_ctx.
 	 */
-	snprintf(exppath, MAXPATHLEN, "%.*s", (int)*aname_len, aname_str);
+	if (*aname_len >= sizeof(exppath)) {
+		err = ENAMETOOLONG;
+		goto errout;
+	}
+	snprintf(exppath, sizeof(exppath), "%.*s", (int)*aname_len, aname_str);
 
 	if (exppath[0] == '/')
 		op_ctx->ctx_export = get_gsh_export_by_path(exppath, false);
diff --git a/src/Protocols/9P/9p_lcreate.c b/src/Protocols/9P/9p_lcreate.c
index 6736e72..d7b4aea 100644
--- a/src/Protocols/9P/9p_lcreate.c
+++ b/src/Protocols/9P/9p_lcreate.c
@@ -60,7 +60,7 @@
 	u32 iounit = _9P_IOUNIT;
 
 	struct fsal_obj_handle *pentry_newfile = NULL;
-	char file_name[MAXNAMLEN];
+	char file_name[MAXNAMLEN+1];
 	fsal_status_t fsal_status;
 	fsal_openflags_t openflags = 0;
 
@@ -94,7 +94,13 @@
 				 EXPORT_OPTION_WRITE_ACCESS) == 0)
 		return _9p_rerror(req9p, msgtag, EROFS, plenout, preply);
 
-	snprintf(file_name, MAXNAMLEN, "%.*s", *name_len, name_str);
+	if (*name_len >= sizeof(file_name)) {
+		LogDebug(COMPONENT_9P, "request with name too long (%u)",
+			 *name_len);
+		return _9p_rerror(req9p, msgtag, ENAMETOOLONG, plenout,
+				  preply);
+	}
+	snprintf(file_name, sizeof(file_name), "%.*s", *name_len, name_str);
 
 	_9p_openflags2FSAL(flags, &openflags);
 	pfid->state->state_data.fid.share_access =
diff --git a/src/Protocols/9P/9p_link.c b/src/Protocols/9P/9p_link.c
index 06a0bc1..ddb10c2 100644
--- a/src/Protocols/9P/9p_link.c
+++ b/src/Protocols/9P/9p_link.c
@@ -56,7 +56,7 @@
 	struct _9p_fid *ptargetfid = NULL;
 
 	fsal_status_t fsal_status;
-	char link_name[MAXNAMLEN];
+	char link_name[MAXNAMLEN+1];
 
 	/* Get data */
 	_9p_getptr(cursor, msgtag, u16);
@@ -97,7 +97,13 @@
 	}
 
 	/* Let's do the job */
-	snprintf(link_name, MAXNAMLEN, "%.*s", *name_len, name_str);
+	if (*name_len >= sizeof(link_name)) {
+		LogDebug(COMPONENT_9P, "request with name too long (%u)",
+			 *name_len);
+		return _9p_rerror(req9p, msgtag, ENAMETOOLONG, plenout,
+				  preply);
+	}
+	snprintf(link_name, sizeof(link_name), "%.*s", *name_len, name_str);
 
 	fsal_status = fsal_link(ptargetfid->pentry, pdfid->pentry, link_name);
 
diff --git a/src/Protocols/9P/9p_lock.c b/src/Protocols/9P/9p_lock.c
index 8cf4930..45acd3e 100644
--- a/src/Protocols/9P/9p_lock.c
+++ b/src/Protocols/9P/9p_lock.c
@@ -87,7 +87,7 @@
 	memset(&lock, 0, sizeof(lock));
 	memset(&conflict, 0, sizeof(conflict));
 
-	char name[MAXNAMLEN];
+	char name[MAXNAMLEN+1];
 
 	struct addrinfo hints, *result;
 	struct sockaddr_storage client_addr;
@@ -126,7 +126,13 @@
 	/* Tmp hook to avoid lock issue when compiling kernels.
 	 * This should not impact ONE client only
 	 * get the client's ip addr */
-	snprintf(name, MAXNAMLEN, "%.*s", *client_id_len, client_id_str);
+	if (*client_id_len >= sizeof(name)) {
+		LogDebug(COMPONENT_9P, "request with name too long (%u)",
+			 *client_id_len);
+		return _9p_rerror(req9p, msgtag, ENAMETOOLONG, plenout,
+				  preply);
+	}
+	snprintf(name, sizeof(name), "%.*s", *client_id_len, client_id_str);
 
 	memset((char *)&hints, 0, sizeof(struct addrinfo));
 	hints.ai_family = AF_INET;
diff --git a/src/Protocols/9P/9p_mkdir.c b/src/Protocols/9P/9p_mkdir.c
index a559c1b..de87159 100644
--- a/src/Protocols/9P/9p_mkdir.c
+++ b/src/Protocols/9P/9p_mkdir.c
@@ -57,7 +57,7 @@
 	struct _9p_qid qid_newdir;
 
 	struct fsal_obj_handle *pentry_newdir = NULL;
-	char dir_name[MAXNAMLEN];
+	char dir_name[MAXNAMLEN+1];
 	fsal_status_t fsal_status;
 	struct attrlist sattr;
 
@@ -90,7 +90,13 @@
 				 EXPORT_OPTION_WRITE_ACCESS) == 0)
 		return _9p_rerror(req9p, msgtag, EROFS, plenout, preply);
 
-	snprintf(dir_name, MAXNAMLEN, "%.*s", *name_len, name_str);
+	if (*name_len >= sizeof(dir_name)) {
+		LogDebug(COMPONENT_9P, "request with name too long (%u)",
+			 *name_len);
+		return _9p_rerror(req9p, msgtag, ENAMETOOLONG, plenout,
+				  preply);
+	}
+	snprintf(dir_name, sizeof(dir_name), "%.*s", *name_len, name_str);
 
 	fsal_prepare_attrs(&sattr, ATTR_MODE);
 
diff --git a/src/Protocols/9P/9p_mknod.c b/src/Protocols/9P/9p_mknod.c
index d9ed981..a986f56 100644
--- a/src/Protocols/9P/9p_mknod.c
+++ b/src/Protocols/9P/9p_mknod.c
@@ -59,7 +59,7 @@
 	struct _9p_qid qid_newobj;
 
 	struct fsal_obj_handle *pentry_newobj = NULL;
-	char obj_name[MAXNAMLEN];
+	char obj_name[MAXNAMLEN+1];
 	uint64_t fileid = 0LL;
 	fsal_status_t fsal_status;
 	object_file_type_t nodetype;
@@ -97,7 +97,13 @@
 				 EXPORT_OPTION_WRITE_ACCESS) == 0)
 		return _9p_rerror(req9p, msgtag, EROFS, plenout, preply);
 
-	snprintf(obj_name, MAXNAMLEN, "%.*s", *name_len, name_str);
+	if (*name_len >= sizeof(obj_name)) {
+		LogDebug(COMPONENT_9P, "request with name too long (%u)",
+			 *name_len);
+		return _9p_rerror(req9p, msgtag, ENAMETOOLONG, plenout,
+				  preply);
+	}
+	snprintf(obj_name, sizeof(obj_name), "%.*s", *name_len, name_str);
 
 	/* Set the nodetype */
 	if (S_ISDIR(*mode))
diff --git a/src/Protocols/9P/9p_rename.c b/src/Protocols/9P/9p_rename.c
index 6616097..f54bc60 100644
--- a/src/Protocols/9P/9p_rename.c
+++ b/src/Protocols/9P/9p_rename.c
@@ -54,7 +54,7 @@
 	struct _9p_fid *pfid = NULL;
 	struct _9p_fid *pdfid = NULL;
 
-	char newname[MAXNAMLEN];
+	char newname[MAXNAMLEN+1];
 	fsal_status_t fsal_status;
 
 	/* Get data */
@@ -94,7 +94,13 @@
 		return _9p_rerror(req9p, msgtag, EIO, plenout, preply);
 	}
 
-	snprintf(newname, MAXNAMLEN, "%.*s", *name_len, name_str);
+	if (*name_len >= sizeof(newname)) {
+		LogDebug(COMPONENT_9P, "request with name too long (%u)",
+			 *name_len);
+		return _9p_rerror(req9p, msgtag, ENAMETOOLONG, plenout,
+				  preply);
+	}
+	snprintf(newname, sizeof(newname), "%.*s", *name_len, name_str);
 
 	fsal_status = fsal_rename(pfid->ppentry, pfid->name, pdfid->pentry,
 				  newname);
diff --git a/src/Protocols/9P/9p_renameat.c b/src/Protocols/9P/9p_renameat.c
index 3bee7bc..6ac5ff0 100644
--- a/src/Protocols/9P/9p_renameat.c
+++ b/src/Protocols/9P/9p_renameat.c
@@ -58,8 +58,8 @@
 
 	fsal_status_t fsal_status;
 
-	char oldname[MAXNAMLEN];
-	char newname[MAXNAMLEN];
+	char oldname[MAXNAMLEN+1];
+	char newname[MAXNAMLEN+1];
 
 	/* Get data */
 	_9p_getptr(cursor, msgtag, u16);
@@ -103,8 +103,21 @@
 		return _9p_rerror(req9p, msgtag, EROFS, plenout, preply);
 
 	/* Let's do the job */
-	snprintf(oldname, MAXNAMLEN, "%.*s", *oldname_len, oldname_str);
-	snprintf(newname, MAXNAMLEN, "%.*s", *newname_len, newname_str);
+	if (*oldname_len >= sizeof(oldname)) {
+		LogDebug(COMPONENT_9P, "request with names too long (%u or %u)",
+			 *oldname_len, *newname_len);
+		return _9p_rerror(req9p, msgtag, ENAMETOOLONG, plenout,
+				  preply);
+	}
+	snprintf(oldname, sizeof(oldname), "%.*s", *oldname_len, oldname_str);
+
+	if (*newname_len >= sizeof(newname)) {
+		LogDebug(COMPONENT_9P, "request with names too long (%u or %u)",
+			 *oldname_len, *newname_len);
+		return _9p_rerror(req9p, msgtag, ENAMETOOLONG, plenout,
+				  preply);
+	}
+	snprintf(newname, sizeof(newname), "%.*s", *newname_len, newname_str);
 
 	fsal_status = fsal_rename(poldfid->pentry, oldname, pnewfid->pentry,
 				  newname);
diff --git a/src/Protocols/9P/9p_symlink.c b/src/Protocols/9P/9p_symlink.c
index 1b5dbfc..d91e34f 100644
--- a/src/Protocols/9P/9p_symlink.c
+++ b/src/Protocols/9P/9p_symlink.c
@@ -59,7 +59,7 @@
 	struct _9p_qid qid_symlink;
 
 	struct fsal_obj_handle *pentry_symlink = NULL;
-	char symlink_name[MAXNAMLEN];
+	char symlink_name[MAXNAMLEN+1];
 	char *link_content = NULL;
 	fsal_status_t fsal_status;
 	uint32_t mode = 0777;
@@ -95,7 +95,14 @@
 				 EXPORT_OPTION_WRITE_ACCESS) == 0)
 		return _9p_rerror(req9p, msgtag, EROFS, plenout, preply);
 
-	snprintf(symlink_name, MAXNAMLEN, "%.*s", *name_len, name_str);
+	if (*name_len >= sizeof(symlink_name)) {
+		LogDebug(COMPONENT_9P, "request with name too long (%u)",
+			 *name_len);
+		return _9p_rerror(req9p, msgtag, ENAMETOOLONG, plenout,
+				  preply);
+	}
+	snprintf(symlink_name, sizeof(symlink_name), "%.*s", *name_len,
+		 name_str);
 
 	link_content = gsh_malloc(*linkcontent_len + 1);
 
diff --git a/src/Protocols/9P/9p_unlinkat.c b/src/Protocols/9P/9p_unlinkat.c
index aba57c5..6192df3 100644
--- a/src/Protocols/9P/9p_unlinkat.c
+++ b/src/Protocols/9P/9p_unlinkat.c
@@ -55,7 +55,7 @@
 	struct _9p_fid *pdfid = NULL;
 
 	fsal_status_t fsal_status;
-	char name[MAXNAMLEN];
+	char name[MAXNAMLEN+1];
 
 	/* Get data */
 	_9p_getptr(cursor, msgtag, u16);
@@ -85,7 +85,13 @@
 		return _9p_rerror(req9p, msgtag, EROFS, plenout, preply);
 
 	/* Let's do the job */
-	snprintf(name, MAXNAMLEN, "%.*s", *name_len, name_str);
+	if (*name_len >= sizeof(name)) {
+		LogDebug(COMPONENT_9P, "request with name too long (%u)",
+			 *name_len);
+		return _9p_rerror(req9p, msgtag, ENAMETOOLONG, plenout,
+				  preply);
+	}
+	snprintf(name, sizeof(name), "%.*s", *name_len, name_str);
 
 	fsal_status = fsal_remove(pdfid->pentry, name);
 	if (FSAL_IS_ERROR(fsal_status))
diff --git a/src/Protocols/9P/9p_walk.c b/src/Protocols/9P/9p_walk.c
index 94c6dc3..ef06e5b 100644
--- a/src/Protocols/9P/9p_walk.c
+++ b/src/Protocols/9P/9p_walk.c
@@ -55,7 +55,7 @@
 	char *wnames_str;
 	fsal_status_t fsal_status;
 	struct fsal_obj_handle *pentry = NULL;
-	char name[MAXNAMLEN];
+	char name[MAXNAMLEN+1];
 
 	u16 *nwqid;
 
@@ -102,7 +102,12 @@
 
 		for (i = 0; i < *nwname; i++) {
 			_9p_getstr(cursor, wnames_len, wnames_str);
-			snprintf(name, MAXNAMLEN, "%.*s", *wnames_len,
+			if (*wnames_len >= sizeof(name)) {
+				gsh_free(pnewfid);
+				return _9p_rerror(req9p, msgtag, ENAMETOOLONG,
+						  plenout, preply);
+			}
+			snprintf(name, sizeof(name), "%.*s", *wnames_len,
 				 wnames_str);
 
 			LogDebug(COMPONENT_9P,
@@ -133,7 +138,7 @@
 
 		pnewfid->ppentry = pfid->pentry;
 
-		strncpy(pnewfid->name, name, MAXNAMLEN-1);
+		strncpy(pnewfid->name, name, MAXNAMLEN);
 
 		/* gdata ref is not hold : the pfid, which use same gdata */
 		/*  will be clunked after pnewfid */
diff --git a/src/Protocols/9P/9p_xattrcreate.c b/src/Protocols/9P/9p_xattrcreate.c
index 320cae5..c516e20 100644
--- a/src/Protocols/9P/9p_xattrcreate.c
+++ b/src/Protocols/9P/9p_xattrcreate.c
@@ -60,7 +60,7 @@
 	struct _9p_fid *pfid = NULL;
 
 	fsal_status_t fsal_status;
-	char name[MAXNAMLEN];
+	char name[MAXNAMLEN+1];
 
 	/* Get data */
 	_9p_getptr(cursor, msgtag, u16);
@@ -92,7 +92,13 @@
 				 EXPORT_OPTION_WRITE_ACCESS) == 0)
 		return _9p_rerror(req9p, msgtag, EROFS, plenout, preply);
 
-	snprintf(name, MAXNAMLEN, "%.*s", *name_len, name_str);
+	if (*name_len >= sizeof(name)) {
+		LogDebug(COMPONENT_9P, "request with name too long (%u)",
+			 *name_len);
+		return _9p_rerror(req9p, msgtag, ENAMETOOLONG, plenout,
+				  preply);
+	}
+	snprintf(name, sizeof(name), "%.*s", *name_len, name_str);
 
 	if (*size == 0LL) {
 		/* Size == 0 : this is in fact a call to removexattr */
diff --git a/src/Protocols/9P/9p_xattrwalk.c b/src/Protocols/9P/9p_xattrwalk.c
index 4ec1cab..6e9c81e 100644
--- a/src/Protocols/9P/9p_xattrwalk.c
+++ b/src/Protocols/9P/9p_xattrwalk.c
@@ -57,7 +57,7 @@
 	size_t attrsize = 0;
 
 	fsal_status_t fsal_status;
-	char name[MAXNAMLEN];
+	char name[MAXNAMLEN+1];
 	fsal_xattrent_t xattrs_arr[XATTRS_ARRAY_LEN];
 	int eod_met = false;
 	unsigned int nb_xattrs_read = 0;
@@ -111,7 +111,13 @@
 	memcpy((char *)pxattrfid, (char *)pfid, sizeof(struct _9p_fid));
 	pxattrfid->state = NULL;
 
-	snprintf(name, MAXNAMLEN, "%.*s", *name_len, name_str);
+	if (*name_len >= sizeof(name)) {
+		LogDebug(COMPONENT_9P, "request with name too long (%u)",
+			 *name_len);
+		return _9p_rerror(req9p, msgtag, ENAMETOOLONG, plenout,
+				  preply);
+	}
+	snprintf(name, sizeof(name), "%.*s", *name_len, name_str);
 
 	pxattrfid->specdata.xattr.xattr_content = gsh_malloc(XATTR_BUFFERSIZE);
 
diff --git a/src/Protocols/NFS/nfs4_op_exchange_id.c b/src/Protocols/NFS/nfs4_op_exchange_id.c
index 5dd2a3a..a75d0d7 100644
--- a/src/Protocols/NFS/nfs4_op_exchange_id.c
+++ b/src/Protocols/NFS/nfs4_op_exchange_id.c
@@ -85,11 +85,13 @@
 	nfs_client_id_t *conf;
 	nfs_client_id_t *unconf;
 	int rc;
-	int len;
+	int owner_len, scope_len;
 	char *temp;
 	bool update;
 	uint32_t pnfs_flags;
 	in_addr_t server_addr = 0;
+	char cid_server_owner[MAXNAMLEN+1]; /* max hostname length */
+	const char cid_server_scope_suffix[] = "_NFS-Ganesha";
 	/* Arguments and response */
 	EXCHANGE_ID4args * const arg_EXCHANGE_ID4 =
 	    &op->nfs_argop4_u.opexchange_id;
@@ -306,20 +308,15 @@
 	       arg_EXCHANGE_ID4->eia_clientowner.co_verifier,
 	       NFS4_VERIFIER_SIZE);
 
-	if (gethostname(unconf->cid_server_owner,
-			sizeof(unconf->cid_server_owner)) == -1) {
+	if (gethostname(cid_server_owner,
+			sizeof(cid_server_owner)) == -1) {
 		/* Free the clientid record and return */
 		free_client_id(unconf);
 		res_EXCHANGE_ID4->eir_status = NFS4ERR_SERVERFAULT;
 		goto out;
 	}
 
-	snprintf(unconf->cid_server_scope,
-		 sizeof(unconf->cid_server_scope),
-		 "%s_NFS-Ganesha",
-		 unconf->cid_server_owner);
-
-	LogDebug(COMPONENT_CLIENTID, "Serving IP %s", unconf->cid_server_scope);
+	LogDebug(COMPONENT_CLIENTID, "Serving IP %s", cid_server_owner);
 
 	rc = nfs_client_id_insert(unconf);
 
@@ -343,21 +340,24 @@
 
 	res_EXCHANGE_ID4_ok->eir_state_protect.spr_how = SP4_NONE;
 
-	len = strlen(unconf->cid_server_owner);
-	temp = gsh_malloc(len + 1);
-	memcpy(temp, unconf->cid_server_owner, len + 1);
+	owner_len = strlen(cid_server_owner);
+	temp = gsh_malloc(owner_len + 1);
+	memcpy(temp, cid_server_owner, owner_len + 1);
 
-	res_EXCHANGE_ID4_ok->eir_server_owner.so_major_id.so_major_id_len = len;
+	res_EXCHANGE_ID4_ok->eir_server_owner.so_major_id.so_major_id_len =
+	    owner_len;
 	res_EXCHANGE_ID4_ok->eir_server_owner.so_major_id.so_major_id_val =
 	    temp;
 
 	res_EXCHANGE_ID4_ok->eir_server_owner.so_minor_id = 0;
 
-	len = strlen(unconf->cid_server_scope);
-	temp = gsh_malloc(len + 1);
-	memcpy(temp, unconf->cid_server_scope, len + 1);
+	scope_len = strlen(cid_server_scope_suffix);
+	temp = gsh_malloc(owner_len + scope_len + 1);
+	memcpy(temp, cid_server_owner, owner_len);
+	memcpy(temp + owner_len, cid_server_scope_suffix, scope_len + 1);
 
-	res_EXCHANGE_ID4_ok->eir_server_scope.eir_server_scope_len = len;
+	res_EXCHANGE_ID4_ok->eir_server_scope.eir_server_scope_len =
+	    owner_len + scope_len + 1;
 	res_EXCHANGE_ID4_ok->eir_server_scope.eir_server_scope_val = temp;
 
 	res_EXCHANGE_ID4_ok->eir_server_impl_id.eir_server_impl_id_len = 0;
diff --git a/src/SAL/nfs4_recovery.c b/src/SAL/nfs4_recovery.c
index 1d10c4a..29979db 100644
--- a/src/SAL/nfs4_recovery.c
+++ b/src/SAL/nfs4_recovery.c
@@ -212,7 +212,7 @@
 	const char *str_client_addr = "(unknown)";
 	char cidstr[PATH_MAX] = { 0, };
 	struct display_buffer dspbuf = {sizeof(cidstr), cidstr, cidstr};
-	char cidstr_len[10];
+	char cidstr_len[20];
 	int total_len;
 
 	/* get the caller's IP addr */
@@ -256,7 +256,7 @@
 	char *buf = "unknown";
 	char cidstr[PATH_MAX] = { 0, };
 	struct display_buffer       dspbuf = {sizeof(cidstr), cidstr, cidstr};
-	char                         cidstr_len[10];
+	char                         cidstr_len[20];
 	int total_len;
 
 	/* get the caller's IP addr */
@@ -1286,18 +1286,12 @@
 
 static int ip_match(char *ip, nfs_client_id_t *cid)
 {
-	LogDebug(COMPONENT_STATE, "NFS Server V4 match ip %s with (%s) or (%s)",
-		 ip, cid->cid_server_owner,
-		 cid->cid_client_record->cr_client_val);
+	LogDebug(COMPONENT_STATE, "NFS Server V4 match ip %s with (%s)",
+		 ip, cid->cid_client_record->cr_client_val);
 
 	if (strlen(ip) == 0)	/* No IP all are matching */
 		return 1;
 
-	if ((strlen(cid->cid_server_owner) > 0) &&	/* Set only for v4.1 */
-	    (strncmp(ip, cid->cid_server_owner, strlen(cid->cid_server_owner))
-	     == 0))
-		return 1;
-
 	if (strstr(cid->cid_client_record->cr_client_val, ip) != NULL)
 		return 1;
 
diff --git a/src/include/9p.h b/src/include/9p.h
index b29420e..f020cec 100644
--- a/src/include/9p.h
+++ b/src/include/9p.h
@@ -304,7 +304,7 @@
 	struct _9p_qid qid;
 	struct state_t *state;
 	struct fsal_obj_handle *ppentry;
-	char name[MAXNAMLEN];
+	char name[MAXNAMLEN+1];
 	u32 opens;
 	union {
 		u32 iounit;
diff --git a/src/include/sal_data.h b/src/include/sal_data.h
index a6a2ecd..7acde6e 100644
--- a/src/include/sal_data.h
+++ b/src/include/sal_data.h
@@ -685,10 +685,6 @@
 	} cid_cb;		/*< Version specific callback information */
 	time_t first_path_down_resp_time;  /* Time when the server first sent
 					       NFS4ERR_CB_PATH_DOWN */
-	char cid_server_owner[MAXNAMLEN + 1];	/*< Server owner.
-						 * @note Why is this
-						 * stored per-client? */
-	char cid_server_scope[MAXNAMLEN + 1];	/*< Server scope */
 	unsigned int cid_nb_session;	/*< Number of sessions stored */
 	nfs41_session_slot_t cid_create_session_slot; /*< Cached response to
 							  last CREATE_SESSION */