]> err.no Git - linux-2.6/commitdiff
SUNRPC: Make sure server name is reasonable before trying to print it
authorChuck Lever <chuck.lever@oracle.com>
Tue, 11 Sep 2007 22:00:20 +0000 (18:00 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Tue, 9 Oct 2007 21:16:42 +0000 (17:16 -0400)
Check the length of the passed-in server name before trying to print it in
the log.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
net/sunrpc/clnt.c

index c3d571abcded265d23d0079705d4cdfa96d9345c..0357819ffdb0ee865ebcc0ced755fa67b13d846f 100644 (file)
@@ -127,7 +127,14 @@ static struct rpc_clnt * rpc_new_client(struct rpc_xprt *xprt, char *servname, s
        struct rpc_clnt         *clnt = NULL;
        struct rpc_auth         *auth;
        int err;
-       int len;
+       size_t len;
+
+       /* sanity check the name before trying to print it */
+       err = -EINVAL;
+       len = strlen(servname);
+       if (len > RPC_MAXNETNAMELEN)
+               goto out_no_rpciod;
+       len++;
 
        dprintk("RPC:       creating %s client for %s (xprt %p)\n",
                        program->name, servname, xprt);
@@ -148,7 +155,6 @@ static struct rpc_clnt * rpc_new_client(struct rpc_xprt *xprt, char *servname, s
        clnt->cl_parent = clnt;
 
        clnt->cl_server = clnt->cl_inline_name;
-       len = strlen(servname) + 1;
        if (len > sizeof(clnt->cl_inline_name)) {
                char *buf = kmalloc(len, GFP_KERNEL);
                if (buf != 0)