diff options
| author | Trond Myklebust <trond.myklebust@primarydata.com> | 2017-02-19 16:08:28 -0500 |
|---|---|---|
| committer | Anna Schumaker <Anna.Schumaker@Netapp.com> | 2017-02-21 16:56:16 -0500 |
| commit | c065eeea3ba03232cb8aaf9d3dc7ad0a9fcb267b (patch) | |
| tree | 15b359f9e6e199136d37cfb0a08217042377b824 | |
| parent | 6da59ce2fd2047fd9cb141479f20d5f84614e84f (diff) | |
NFSv4: Replace callback string decode function with a generic
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Reviewed-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
| -rw-r--r-- | fs/nfs/callback_xdr.c | 30 |
1 files changed, 8 insertions, 22 deletions
diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c index e732a65db546..2ade5cb52b8e 100644 --- a/fs/nfs/callback_xdr.c +++ b/fs/nfs/callback_xdr.c | |||
| @@ -83,23 +83,15 @@ static __be32 *read_buf(struct xdr_stream *xdr, size_t nbytes) | |||
| 83 | return p; | 83 | return p; |
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | static __be32 decode_string(struct xdr_stream *xdr, unsigned int *len, const char **str) | 86 | static __be32 decode_string(struct xdr_stream *xdr, unsigned int *len, |
| 87 | const char **str, size_t maxlen) | ||
| 87 | { | 88 | { |
| 88 | __be32 *p; | 89 | ssize_t err; |
| 89 | |||
| 90 | p = read_buf(xdr, 4); | ||
| 91 | if (unlikely(p == NULL)) | ||
| 92 | return htonl(NFS4ERR_RESOURCE); | ||
| 93 | *len = ntohl(*p); | ||
| 94 | |||
| 95 | if (*len != 0) { | ||
| 96 | p = read_buf(xdr, *len); | ||
| 97 | if (unlikely(p == NULL)) | ||
| 98 | return htonl(NFS4ERR_RESOURCE); | ||
| 99 | *str = (const char *)p; | ||
| 100 | } else | ||
| 101 | *str = NULL; | ||
| 102 | 90 | ||
| 91 | err = xdr_stream_decode_opaque_inline(xdr, (void **)str, maxlen); | ||
| 92 | if (err < 0) | ||
| 93 | return cpu_to_be32(NFS4ERR_RESOURCE); | ||
| 94 | *len = err; | ||
| 103 | return 0; | 95 | return 0; |
| 104 | } | 96 | } |
| 105 | 97 | ||
| @@ -162,15 +154,9 @@ static __be32 decode_compound_hdr_arg(struct xdr_stream *xdr, struct cb_compound | |||
| 162 | __be32 *p; | 154 | __be32 *p; |
| 163 | __be32 status; | 155 | __be32 status; |
| 164 | 156 | ||
| 165 | status = decode_string(xdr, &hdr->taglen, &hdr->tag); | 157 | status = decode_string(xdr, &hdr->taglen, &hdr->tag, CB_OP_TAGLEN_MAXSZ); |
| 166 | if (unlikely(status != 0)) | 158 | if (unlikely(status != 0)) |
| 167 | return status; | 159 | return status; |
| 168 | /* We do not like overly long tags! */ | ||
| 169 | if (hdr->taglen > CB_OP_TAGLEN_MAXSZ) { | ||
| 170 | printk("NFS: NFSv4 CALLBACK %s: client sent tag of length %u\n", | ||
| 171 | __func__, hdr->taglen); | ||
| 172 | return htonl(NFS4ERR_RESOURCE); | ||
| 173 | } | ||
| 174 | p = read_buf(xdr, 12); | 160 | p = read_buf(xdr, 12); |
| 175 | if (unlikely(p == NULL)) | 161 | if (unlikely(p == NULL)) |
| 176 | return htonl(NFS4ERR_RESOURCE); | 162 | return htonl(NFS4ERR_RESOURCE); |
