From 5acea014b00d042f6deb9b8da5c589df9e8057dd Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 21 Sep 2020 15:11:13 +0200 Subject: [PATCH 1/3] archive/iso9660: remove unused macro CEILING() --- src/archive/plugins/Iso9660ArchivePlugin.cxx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/archive/plugins/Iso9660ArchivePlugin.cxx b/src/archive/plugins/Iso9660ArchivePlugin.cxx index be319d2a7..2f463364f 100644 --- a/src/archive/plugins/Iso9660ArchivePlugin.cxx +++ b/src/archive/plugins/Iso9660ArchivePlugin.cxx @@ -38,8 +38,6 @@ #include #include -#define CEILING(x, y) ((x+(y-1))/y) - struct Iso9660 { iso9660_t *const iso; From 79b2366387dcd5f4ccae50eacf1ae06973f01d83 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 21 Sep 2020 14:24:50 +0200 Subject: [PATCH 2/3] archive/iso9660: fix odd seeking bug (assertion failure) Skip the beginning of a sector if the last seek was odd, and clear the buffer on seek. --- src/archive/plugins/Iso9660ArchivePlugin.cxx | 26 +++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/archive/plugins/Iso9660ArchivePlugin.cxx b/src/archive/plugins/Iso9660ArchivePlugin.cxx index 2f463364f..b758b929c 100644 --- a/src/archive/plugins/Iso9660ArchivePlugin.cxx +++ b/src/archive/plugins/Iso9660ArchivePlugin.cxx @@ -182,10 +182,21 @@ class Iso9660InputStream final : public InputStream { fill = nbytes; position = 0; } + + void Clear() noexcept { + position = fill = 0; + } }; BlockBuffer buffer; + /** + * Skip this number of bytes of the first sector after filling + * the buffer next time. This is used for seeking into the + * middle of a sector. + */ + size_t skip = 0; + public: Iso9660InputStream(const std::shared_ptr &_iso, const char *_uri, @@ -208,7 +219,9 @@ public: if (new_offset > size) throw std::runtime_error("Invalid seek offset"); - offset = new_offset; + skip = new_offset % ISO_BLOCKSIZE; + offset = new_offset - skip; + buffer.Clear(); } }; @@ -273,9 +286,20 @@ Iso9660InputStream::Read(void *ptr, size_t read_size) buffer.Append(nbytes); r = buffer.Read(); + + if (skip > 0) { + if (skip >= r.size) + throw std::runtime_error("Premature end of ISO9660 track"); + + buffer.Consume(skip); + skip = 0; + + r = buffer.Read(); + } } assert(!r.empty()); + assert(skip == 0); size_t nbytes = std::min(read_size, r.size); memcpy(ptr, r.data, nbytes); From 566787f0412a6c3b22083055938323867c44f6c4 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 21 Sep 2020 15:14:43 +0200 Subject: [PATCH 3/3] release v0.21.26 --- NEWS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 9ece34870..307a4575e 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,4 @@ -ver 0.21.26 (not yet released) +ver 0.21.26 (2020/09/21) * database - inotify: obey ".mpdignore" files * output