lockd: Ensure NSM strings aren't longer than protocol allows
authorChuck Lever <chuck.lever@oracle.com>
Fri, 14 Mar 2008 18:25:32 +0000 (14:25 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Wed, 19 Mar 2008 22:00:54 +0000 (18:00 -0400)
Introduce a special helper function to check the length of NSM strings
before they are placed on the wire.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
fs/lockd/mon.c

index 908b23f..84fd84c 100644 (file)
@@ -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)
 {