client/FileCommands: validate the given offset

This commit is contained in:
Max Kellermann 2021-01-21 16:55:47 +01:00
parent 3b3c1d466d
commit 6e33566cee
1 changed files with 11 additions and 0 deletions

View File

@ -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;