diff options
author | mux <mux@FreeBSD.org> | 2004-04-12 13:02:21 +0000 |
---|---|---|
committer | mux <mux@FreeBSD.org> | 2004-04-12 13:02:21 +0000 |
commit | 006bc4ac4c098febff8ef46213db4475f141fad1 (patch) | |
tree | b28692249e92e038cc5ef294ff209858170b5a76 /sys/nfsserver/nfs_serv.c | |
parent | e26da574d5030a4978730fbd3df438acc7ce8f7d (diff) | |
download | FreeBSD-src-006bc4ac4c098febff8ef46213db4475f141fad1.zip FreeBSD-src-006bc4ac4c098febff8ef46213db4475f141fad1.tar.gz |
Don't send the available space as is in the FSSTAT call. Under
FreeBSD, we can have a negative available space value, but the
corresponding fields in the NFS protocol are unsigned. So
trnucate the value to 0 if it's negative, so that the client
doesn't receive absurdly high values.
Tested by: cognet
Diffstat (limited to 'sys/nfsserver/nfs_serv.c')
-rw-r--r-- | sys/nfsserver/nfs_serv.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/sys/nfsserver/nfs_serv.c b/sys/nfsserver/nfs_serv.c index e76fd5c..258da54 100644 --- a/sys/nfsserver/nfs_serv.c +++ b/sys/nfsserver/nfs_serv.c @@ -3808,7 +3808,16 @@ nfsrv_statfs(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, tval = (u_quad_t)sf->f_bfree; tval *= (u_quad_t)sf->f_bsize; txdr_hyper(tval, &sfp->sf_fbytes); - tval = (u_quad_t)sf->f_bavail; + /* + * Don't send negative values for available space, + * since this field is unsigned in the NFS protocol. + * Otherwise, the client would see absurdly high + * numbers for free space. + */ + if (sf->f_bavail < 0) + tval = 0; + else + tval = (u_quad_t)sf->f_bavail; tval *= (u_quad_t)sf->f_bsize; txdr_hyper(tval, &sfp->sf_abytes); sfp->sf_tfiles.nfsuquad[0] = 0; @@ -3823,7 +3832,10 @@ nfsrv_statfs(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, sfp->sf_bsize = txdr_unsigned(sf->f_bsize); sfp->sf_blocks = txdr_unsigned(sf->f_blocks); sfp->sf_bfree = txdr_unsigned(sf->f_bfree); - sfp->sf_bavail = txdr_unsigned(sf->f_bavail); + if (sf->f_bavail < 0) + sfp->sf_bavail = 0; + else + sfp->sf_bavail = txdr_unsigned(sf->f_bavail); } nfsmout: if (vp) |