From: Chuck Lever Date: Fri, 14 Mar 2008 18:25:32 +0000 (-0400) Subject: lockd: Ensure NSM strings aren't longer than protocol allows X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=099bd05f27ff24a3041d54e7ed42d2eb681484b9;p=GitHub%2Fexynos8895%2Fandroid_kernel_samsung_universal8895.git 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. Signed-off-by: Chuck Lever Signed-off-by: Trond Myklebust --- diff --git a/fs/lockd/mon.c b/fs/lockd/mon.c index 908b23fadd05..84fd84cb67b7 100644 --- a/fs/lockd/mon.c +++ b/fs/lockd/mon.c @@ -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) {