diff --git a/NEWS b/NEWS index bd4caf30b..c43b3b4f8 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,7 @@ ver 0.21.25 (not yet released) * protocol: - fix crash when using "rangeid" while playing * input + - file: detect premature end of file - smbclient: don't send credentials to MPD clients ver 0.21.24 (2020/06/10) diff --git a/src/input/plugins/FileInputPlugin.cxx b/src/input/plugins/FileInputPlugin.cxx index 989d3de74..0a6f31438 100644 --- a/src/input/plugins/FileInputPlugin.cxx +++ b/src/input/plugins/FileInputPlugin.cxx @@ -26,6 +26,8 @@ #include "system/FileDescriptor.hxx" #include "util/RuntimeError.hxx" +#include // for PRIu64 (PRIoffset) + #include #include @@ -94,6 +96,11 @@ FileInputStream::Read(void *ptr, size_t read_size) nbytes = reader.Read(ptr, read_size); } + if (nbytes == 0 && !IsEOF()) + throw FormatRuntimeError("Unexpected end of file %s" + " at %" PRIoffset " of %" PRIoffset, + GetURI(), GetOffset(), GetSize()); + offset += nbytes; return nbytes; }