From 9c8a2265b5ecb5d10846eabb1e2e29adad4f715d Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 2 Mar 2019 14:47:52 -0500 Subject: [PATCH] Breaks infinite loop where signature[0] == 0x1f but some of the rest doesn't match. --- Storage/Tape/Formats/CAS.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Storage/Tape/Formats/CAS.cpp b/Storage/Tape/Formats/CAS.cpp index 9b6b477d2..8662e1bef 100644 --- a/Storage/Tape/Formats/CAS.cpp +++ b/Storage/Tape/Formats/CAS.cpp @@ -75,8 +75,10 @@ CAS::CAS(const std::string &file_name) { const auto signature = file.read(8); if(signature.size() != 8) break; if(std::memcmp(signature.data(), header_signature, 8)) { + if(!chunks_.empty()) chunks_.back().data.push_back(signature[0]); + // Check for other 1fs in this stream, and repeat from there if any. - for(size_t c = 0; c < 8; ++c) { + for(size_t c = 1; c < 8; ++c) { if(signature[c] == 0x1f) { file.seek(header_position + long(c), SEEK_SET); break;