From: Ronnie Sahlberg Date: Sat, 25 Jun 2011 02:13:11 +0000 (+1000) Subject: handle the case where we try a multi-read that is completely beyond the end of file. X-Git-Tag: upstream/1.9.6^2~388 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=215228a23de45d62bb5154e919d23da2b435880b;p=deb_libnfs.git handle the case where we try a multi-read that is completely beyond the end of file. when a multi-read was completely beyond the end of file, this caused us to invoke the callback with a 'read-count' of <0 which the callback would treat as a failure. This would then cause the callback to treat the data pointer as an error string and try to use it for nfs_set_error(). Since the data pointer was actually a real binary databuffer and not an error string this would cause the NFS error string to look like it contained garbage data. In this case, where the multi-read fails to read any data at all since it if fully beyond end of file, make sure to invoke the callback with a read-count of 0 --- diff --git a/lib/libnfs.c b/lib/libnfs.c index 996b988..d1f4f0e 100644 --- a/lib/libnfs.c +++ b/lib/libnfs.c @@ -889,7 +889,11 @@ static void nfs_pread_mcb(struct rpc_context *rpc _U_, int status, void *command } data->nfsfh->offset = data->max_offset; - data->cb(data->max_offset - data->start_offset, nfs, data->buffer, data->private_data); + if (data->max_offset - data->start_offset >= 0) { + data->cb(data->max_offset - data->start_offset, nfs, data->buffer, data->private_data); + } else { + data->cb(0, nfs, data->buffer, data->private_data); + } free_nfs_cb_data(data); free(mdata); }