summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2021-01-21 16:55:47 +0100
committerMax Kellermann <max@musicpd.org>2021-01-21 16:57:38 +0100
commit6e33566ceeb7e6c4454e44efd203b2e2fcd10feb (patch)
tree434db24d0de7816739aaf8ea65443c8d02628e56 /src
parent3b3c1d466d0d3de16697269b72c289d55935402b (diff)
client/FileCommands: validate the given offset
Diffstat (limited to 'src')
-rw-r--r--src/command/FileCommands.cxx11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/command/FileCommands.cxx b/src/command/FileCommands.cxx
index dc68463aa..4ac239646 100644
--- a/src/command/FileCommands.cxx
+++ b/src/command/FileCommands.cxx
@@ -205,6 +205,17 @@ read_stream_art(Response &r, const char *uri, size_t offset)
const offset_type art_file_size = is->GetSize();
+ if (offset >= art_file_size) {
+ if (offset > art_file_size) {
+ r.Error(ACK_ERROR_ARG, "Offset too large");
+ return CommandResult::ERROR;
+ } else {
+ r.Format("size: %" PRIoffset "\n", art_file_size);
+ r.WriteBinary(nullptr);
+ return CommandResult::OK;
+ }
+ }
+
uint8_t buffer[Response::MAX_BINARY_SIZE];
size_t read_size;