Commit 9c9ff1bc authored by Trond Myklebust's avatar Trond Myklebust

RPC,NFSv3: remove the redundant "memset()" in call_encode(). Fix up the only places

    where this causes a padding error: xdr_encode_fhandle() and unx_marshal()
parent c7c3ee40
......@@ -103,9 +103,7 @@ static struct {
static inline u32 *
xdr_encode_fhandle(u32 *p, struct nfs_fh *fh)
{
*p++ = htonl(fh->size);
memcpy(p, fh->data, fh->size);
return p + XDR_QUADLEN(fh->size);
return xdr_encode_array(p, fh->data, fh->size);
}
static inline u32 *
......
......@@ -324,7 +324,7 @@ encode_compound_hdr(struct xdr_stream *xdr, struct compound_hdr *hdr)
dprintk("encode_compound: tag=%.*s\n", (int)hdr->taglen, hdr->tag);
BUG_ON(hdr->taglen > NFS4_MAXTAGLEN);
RESERVE_SPACE(12+XDR_QUADLEN(hdr->taglen));
RESERVE_SPACE(12+(XDR_QUADLEN(hdr->taglen)<<2));
WRITE32(hdr->taglen);
WRITEMEM(hdr->tag, hdr->taglen);
WRITE32(NFS4_MINOR_VERSION);
......
......@@ -87,7 +87,7 @@ struct xdr_buf {
/*
* Miscellaneous XDR helper functions
*/
u32 * xdr_encode_array(u32 *p, const char *s, unsigned int len);
u32 * xdr_encode_array(u32 *p, const void *s, unsigned int len);
u32 * xdr_encode_string(u32 *p, const char *s);
u32 * xdr_decode_string(u32 *p, char **sp, int *lenp, int maxlen);
u32 * xdr_decode_string_inplace(u32 *p, char **sp, int *lenp, int maxlen);
......
......@@ -149,7 +149,7 @@ unx_marshal(struct rpc_task *task, u32 *p, int ruid)
struct rpc_clnt *clnt = task->tk_client;
struct unx_cred *cred = (struct unx_cred *) task->tk_msg.rpc_cred;
u32 *base, *hold;
int i, n;
int i;
*p++ = htonl(RPC_AUTH_UNIX);
base = p++;
......@@ -158,10 +158,7 @@ unx_marshal(struct rpc_task *task, u32 *p, int ruid)
/*
* Copy the UTS nodename captured when the client was created.
*/
n = clnt->cl_nodelen;
*p++ = htonl(n);
memcpy(p, clnt->cl_nodename, n);
p += (n + 3) >> 2;
p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
/* Note: we don't use real uid if it involves raising privilege */
if (ruid && cred->uc_puid != 0 && cred->uc_pgid != 0) {
......
......@@ -611,9 +611,6 @@ call_encode(struct rpc_task *task)
rcvbuf->page_len = 0;
rcvbuf->len = bufsiz;
/* Zero buffer so we have automatic zero-padding of opaque & string */
memset(task->tk_buffer, 0, bufsiz);
/* Encode header and provided arguments */
encode = task->tk_msg.rpc_proc->p_encode;
if (!(p = call_header(task))) {
......
......@@ -54,7 +54,7 @@ xdr_decode_netobj(u32 *p, struct xdr_netobj *obj)
}
u32 *
xdr_encode_array(u32 *p, const char *array, unsigned int len)
xdr_encode_array(u32 *p, const void *array, unsigned int len)
{
int quadlen = XDR_QUADLEN(len);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment