input/file: detect premature end of file
A bug report (https://github.com/MusicPlayerDaemon/MPD/issues/912) suggests that on Linux, reading on `cifs` files may rarely return 0 (= end of file) before the end of the file has really been reached. But that's just a theory which I need to validate, so this runtime check shall catch this condition before the assertion in DecoderBridge::Read() crashes MPD. Let's see. Closes https://github.com/MusicPlayerDaemon/MPD/issues/912
This commit is contained in:
parent
a43ee97746
commit
d9f9b3df10
1
NEWS
1
NEWS
@ -2,6 +2,7 @@ ver 0.21.25 (not yet released)
|
|||||||
* protocol:
|
* protocol:
|
||||||
- fix crash when using "rangeid" while playing
|
- fix crash when using "rangeid" while playing
|
||||||
* input
|
* input
|
||||||
|
- file: detect premature end of file
|
||||||
- smbclient: don't send credentials to MPD clients
|
- smbclient: don't send credentials to MPD clients
|
||||||
|
|
||||||
ver 0.21.24 (2020/06/10)
|
ver 0.21.24 (2020/06/10)
|
||||||
|
@ -26,6 +26,8 @@
|
|||||||
#include "system/FileDescriptor.hxx"
|
#include "system/FileDescriptor.hxx"
|
||||||
#include "util/RuntimeError.hxx"
|
#include "util/RuntimeError.hxx"
|
||||||
|
|
||||||
|
#include <cinttypes> // for PRIu64 (PRIoffset)
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
@ -94,6 +96,11 @@ FileInputStream::Read(void *ptr, size_t read_size)
|
|||||||
nbytes = reader.Read(ptr, 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;
|
offset += nbytes;
|
||||||
return nbytes;
|
return nbytes;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user