aboutsummaryrefslogtreecommitdiffstats
path: root/src/input/plugins
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-06-21 14:06:31 +0200
committerMax Kellermann <max@duempel.org>2014-06-21 14:06:31 +0200
commit3e4e6f7ced979570588c7e341250ebaea2e3bffb (patch)
treefc14f83d2255e7aa674659444365ffe6e51c4098 /src/input/plugins
parent936eb43c0e00f6e8cee971cbdc2f0bf119e1034b (diff)
downloadmpd-3e4e6f7ced979570588c7e341250ebaea2e3bffb.tar.gz
mpd-3e4e6f7ced979570588c7e341250ebaea2e3bffb.tar.xz
mpd-3e4e6f7ced979570588c7e341250ebaea2e3bffb.zip
input/nfs: never read more than space available in buffer
Avoids off-by-one bug and obsoletes the bug fix in commit 966c4244
Diffstat (limited to 'src/input/plugins')
-rw-r--r--src/input/plugins/NfsInputPlugin.cxx6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/input/plugins/NfsInputPlugin.cxx b/src/input/plugins/NfsInputPlugin.cxx
index 8f63d80a1..baa707738 100644
--- a/src/input/plugins/NfsInputPlugin.cxx
+++ b/src/input/plugins/NfsInputPlugin.cxx
@@ -93,12 +93,14 @@ NfsInputStream::DoRead()
if (remaining <= 0)
return true;
- if (IsBufferFull()) {
+ const size_t buffer_space = GetBufferSpace();
+ if (buffer_space == 0) {
Pause();
return true;
}
- size_t nbytes = std::min<uint64_t>(remaining, 32768);
+ size_t nbytes = std::min<size_t>(std::min<uint64_t>(remaining, 32768),
+ buffer_space);
mutex.unlock();
Error error;