Skip to contentSkip to conversation

lockd: Ensure NSM strings aren't longer than protocol allows

PATCH New Chuck Lever 1 participant 1 message Mar 14, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/6 lockd: Ensure NSM strings aren't longer than protocol allows

Introduce a special helper function to check the length of NSM strings before they are placed on the wire.

---

 fs/lockd/mon.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
fs/lockd/mon.c +9 -0
index 908b23f..84fd84c 100644
@@ -149,6 +149,15 @@ nsm_create(void)
  * XDR functions for NSM.
  */
 
+static __be32 *xdr_encode_nsm_string(__be32 *p, char *string)
+{
+	size_t len = strlen(string);
+
+	if (len > SM_MAXSTRLEN)
+		len = SM_MAXSTRLEN;
+	return xdr_encode_opaque(p, string, len);
+}
+
 static __be32 *
 xdr_encode_common(struct rpc_rqst *rqstp, __be32 *p, struct nsm_args *argp)
 {