Skip to content

Commit

Permalink
Merge pull request #214 from earlchew/issues-206-01
Browse files Browse the repository at this point in the history
Return an error if either readmax or writemax are less than NFSMAXDATA2
  • Loading branch information
sahlberg committed May 10, 2017
2 parents bf7d983 + 2f04142 commit d8d9e55
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions lib/libnfs.c
Expand Up @@ -957,12 +957,27 @@ static void nfs_mount_10_cb(struct rpc_context *rpc, int status, void *command_d
nfs->readmax = res->FSINFO3res_u.resok.rtmax;
nfs->writemax = res->FSINFO3res_u.resok.wtmax;

if (nfs->readmax > NFS_MAX_XFER_SIZE) {
/* The server supports sizes up to rtmax and wtmax, so it is legal
* to use smaller transfers sizes.
*/
if (nfs->readmax > NFS_MAX_XFER_SIZE)
nfs->readmax = NFS_MAX_XFER_SIZE;
else if (nfs->readmax < NFSMAXDATA2) {
rpc_set_error(
rpc, "server max rsize of %" PRIu64, nfs->readmax);
data->cb(-EINVAL, nfs, command_data, data->private_data);
free_nfs_cb_data(data);
return;
}

if (nfs->writemax > NFS_MAX_XFER_SIZE) {
if (nfs->writemax > NFS_MAX_XFER_SIZE)
nfs->writemax = NFS_MAX_XFER_SIZE;
else if (nfs->writemax < NFSMAXDATA2) {
rpc_set_error(
rpc, "server max wsize of %" PRIu64, nfs->writemax);
data->cb(-EINVAL, nfs, command_data, data->private_data);
free_nfs_cb_data(data);
return;
}

memset(&args, 0, sizeof(GETATTR3args));
Expand Down

0 comments on commit d8d9e55

Please sign in to comment.