From 3e4e6f7ced979570588c7e341250ebaea2e3bffb Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 21 Jun 2014 14:06:31 +0200 Subject: input/nfs: never read more than space available in buffer Avoids off-by-one bug and obsoletes the bug fix in commit 966c4244 --- src/input/plugins/NfsInputPlugin.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/input/plugins/NfsInputPlugin.cxx') 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(remaining, 32768); + size_t nbytes = std::min(std::min(remaining, 32768), + buffer_space); mutex.unlock(); Error error; -- cgit v1.2.3