Commit 4c94e13e authored by Christoph Hellwig's avatar Christoph Hellwig Committed by J. Bruce Fields

nfsd: factor out a helper to decode nfstime4 values

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
parent 3c519914
...@@ -234,6 +234,26 @@ static char *savemem(struct nfsd4_compoundargs *argp, __be32 *p, int nbytes) ...@@ -234,6 +234,26 @@ static char *savemem(struct nfsd4_compoundargs *argp, __be32 *p, int nbytes)
return ret; return ret;
} }
/*
* We require the high 32 bits of 'seconds' to be 0, and
* we ignore all 32 bits of 'nseconds'.
*/
static __be32
nfsd4_decode_time(struct nfsd4_compoundargs *argp, struct timespec *tv)
{
DECODE_HEAD;
u64 sec;
READ_BUF(12);
p = xdr_decode_hyper(p, &sec);
tv->tv_sec = sec;
tv->tv_nsec = be32_to_cpup(p++);
if (tv->tv_nsec >= (u32)1000000000)
return nfserr_inval;
DECODE_TAIL;
}
static __be32 static __be32
nfsd4_decode_bitmap(struct nfsd4_compoundargs *argp, u32 *bmval) nfsd4_decode_bitmap(struct nfsd4_compoundargs *argp, u32 *bmval)
{ {
...@@ -267,7 +287,6 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval, ...@@ -267,7 +287,6 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval,
{ {
int expected_len, len = 0; int expected_len, len = 0;
u32 dummy32; u32 dummy32;
u64 sec;
char *buf; char *buf;
DECODE_HEAD; DECODE_HEAD;
...@@ -358,15 +377,10 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval, ...@@ -358,15 +377,10 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval,
dummy32 = be32_to_cpup(p++); dummy32 = be32_to_cpup(p++);
switch (dummy32) { switch (dummy32) {
case NFS4_SET_TO_CLIENT_TIME: case NFS4_SET_TO_CLIENT_TIME:
/* We require the high 32 bits of 'seconds' to be 0, and we ignore
all 32 bits of 'nseconds'. */
READ_BUF(12);
len += 12; len += 12;
p = xdr_decode_hyper(p, &sec); status = nfsd4_decode_time(argp, &iattr->ia_atime);
iattr->ia_atime.tv_sec = (time_t)sec; if (status)
iattr->ia_atime.tv_nsec = be32_to_cpup(p++); return status;
if (iattr->ia_atime.tv_nsec >= (u32)1000000000)
return nfserr_inval;
iattr->ia_valid |= (ATTR_ATIME | ATTR_ATIME_SET); iattr->ia_valid |= (ATTR_ATIME | ATTR_ATIME_SET);
break; break;
case NFS4_SET_TO_SERVER_TIME: case NFS4_SET_TO_SERVER_TIME:
...@@ -382,15 +396,10 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval, ...@@ -382,15 +396,10 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval,
dummy32 = be32_to_cpup(p++); dummy32 = be32_to_cpup(p++);
switch (dummy32) { switch (dummy32) {
case NFS4_SET_TO_CLIENT_TIME: case NFS4_SET_TO_CLIENT_TIME:
/* We require the high 32 bits of 'seconds' to be 0, and we ignore
all 32 bits of 'nseconds'. */
READ_BUF(12);
len += 12; len += 12;
p = xdr_decode_hyper(p, &sec); status = nfsd4_decode_time(argp, &iattr->ia_mtime);
iattr->ia_mtime.tv_sec = sec; if (status)
iattr->ia_mtime.tv_nsec = be32_to_cpup(p++); return status;
if (iattr->ia_mtime.tv_nsec >= (u32)1000000000)
return nfserr_inval;
iattr->ia_valid |= (ATTR_MTIME | ATTR_MTIME_SET); iattr->ia_valid |= (ATTR_MTIME | ATTR_MTIME_SET);
break; break;
case NFS4_SET_TO_SERVER_TIME: case NFS4_SET_TO_SERVER_TIME:
......
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