bug fix: avoid infinite loops by checking for len=0 on read/write

/* we shouldn't ever see this, but a buggy server could
 * send us into an infinite loop. return NFS4ERR_IO */

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
This commit is contained in:
Casey Bodley 2010-10-07 13:20:38 -04:00
parent e4b1bc6ccc
commit bb73eec774

View file

@ -628,6 +628,14 @@ int nfs41_write(
} }
*bytes_written = write_res.resok4.count; *bytes_written = write_res.resok4.count;
/* we shouldn't ever see this, but a buggy server could
* send us into an infinite loop. return NFS4ERR_IO */
if (!write_res.resok4.count) {
status = NFS4ERR_IO;
eprintf("WRITE succeeded with count=0; returning %s\n",
nfs_error_string(status));
}
out: out:
return status; return status;
} }
@ -680,6 +688,14 @@ int nfs41_read(
*data_len_out = read_res.resok4.data_len; *data_len_out = read_res.resok4.data_len;
*eof_out = read_res.resok4.eof; *eof_out = read_res.resok4.eof;
/* we shouldn't ever see this, but a buggy server could
* send us into an infinite loop. return NFS4ERR_IO */
if (!read_res.resok4.data_len && !read_res.resok4.eof) {
status = NFS4ERR_IO;
eprintf("READ succeeded with len=0 and eof=0; returning %s\n",
nfs_error_string(status));
}
out: out:
return status; return status;
} }