diff --git a/build.ps1 b/build.ps1 index d1d8e5a00..8db5b6512 100644 --- a/build.ps1 +++ b/build.ps1 @@ -23,8 +23,8 @@ Try { & wix > $null } Catch { - & dotnet tool install -g --version 6.0.1 wix - & wix extension add -g WixToolset.UI.wixext/6.0.1 + & dotnet tool install -g --version 6.0.2 wix + & wix extension add -g WixToolset.UI.wixext/6.0.2 } if(!(Test-Path -Path $vcpkg)) { diff --git a/src/ASiC_S.cpp b/src/ASiC_S.cpp index 28f837a16..6aa352cd7 100644 --- a/src/ASiC_S.cpp +++ b/src/ASiC_S.cpp @@ -98,7 +98,7 @@ ASiC_S::ASiC_S(const string &path) string tst = z.extract(uri).str(); addSignature(make_unique(file, ::move(doc), tst, this)); metadata.push_back({file, string(mime), xml.str()}); - metadata.push_back({uri, string(ref["MimeType"]), std::move(tst)}); + metadata.push_back({std::move(uri), string(ref["MimeType"]), std::move(tst)}); }; add(file, "text/xml"); } diff --git a/src/ASiContainer.cpp b/src/ASiContainer.cpp index a4c1b0ce9..c180b6312 100644 --- a/src/ASiContainer.cpp +++ b/src/ASiContainer.cpp @@ -170,11 +170,12 @@ void ASiContainer::addDataFile(const string &path, const string &mediaType) { string fileName = File::fileName(path); addDataFileChecks(fileName, mediaType); - auto size = File::fileSize(path); + auto nativePath = File::encodeName(path); + auto size = File::fileSize(nativePath); if(size == 0) THROW("Document file '%s' does not exist or is empty.", path.c_str()); - unique_ptr is = make_unique(File::encodeName(path), ifstream::binary); + unique_ptr is = make_unique(nativePath, ifstream::binary); if(!*is) THROW("Failed to open file for reading: %s.", path.c_str()); if(size <= MAX_MEM_FILE) diff --git a/src/SignatureTST.cpp b/src/SignatureTST.cpp index da1a65dcb..b03da19d6 100644 --- a/src/SignatureTST.cpp +++ b/src/SignatureTST.cpp @@ -123,7 +123,7 @@ void SignatureTST::validate() const string_view method = (ref/DigestMethod)["Algorithm"]; auto uri = util::File::fromUriPath(ref["URI"]); vector digest = file->fileName() == uri ? - dynamic_cast(file)->calcDigest(string(method)) : + static_cast(file)->calcDigest(string(method)) : asicSDoc->fileDigest(uri, method).result(); if(vector digestValue = ref/DigestValue; digest != digestValue) THROW("Reference %s digest does not match", uri.c_str()); diff --git a/src/XMLDocument.h b/src/XMLDocument.h index b518cccc6..271e3c0c6 100644 --- a/src/XMLDocument.h +++ b/src/XMLDocument.h @@ -456,7 +456,7 @@ struct XMLDocument: public unique_free_d, public XMLNode return ctx->status == xmlSecDSigStatusSucceeded; } - static void schemaValidationError(void *ctx, const char *msg, ...) noexcept + static void schemaValidationError(void *ctx, const char *msg, ...) noexcept try { va_list args{}; va_start(args, msg); @@ -469,15 +469,19 @@ struct XMLDocument: public unique_free_d, public XMLNode } else ERR("Schema validation error: %s", m.c_str()); + } catch(const std::exception &e) { + std::printf("Unexpected error: %s", e.what()); } - static void schemaValidationWarning(void */*ctx*/, const char *msg, ...) noexcept + static void schemaValidationWarning(void */*ctx*/, const char *msg, ...) noexcept try { va_list args{}; va_start(args, msg); std::string m = Log::formatArgList(msg, args); va_end(args); WARN("Schema validation warning: %s", m.c_str()); + } catch(const std::exception &e) { + std::printf("Unexpected error: %s", e.what()); } }; diff --git a/src/XmlConf.cpp b/src/XmlConf.cpp index 38608d7b1..c9bb802a7 100644 --- a/src/XmlConf.cpp +++ b/src/XmlConf.cpp @@ -146,7 +146,7 @@ auto XmlConf::Private::loadDoc(const string &path) const void XmlConf::Private::init(const string& path, bool global) { DEBUG("XmlConfPrivate::init(%s, %u)", path.c_str(), global); - if(File::fileSize(path) == 0) + if(File::fileSize(File::encodeName(path)) == 0) return; auto doc = loadDoc(path); diff --git a/src/digidoc-tool.cpp b/src/digidoc-tool.cpp index de4c08ac5..7c961dfdd 100644 --- a/src/digidoc-tool.cpp +++ b/src/digidoc-tool.cpp @@ -1060,4 +1060,7 @@ int main(int argc, char *argv[]) try } catch(const Exception &e) { cout << "Caught Exception:" << endl << e; return EXIT_FAILURE; +} catch(const std::exception &e) { + cout << "Caught Exception:" << endl << e.what(); + return EXIT_FAILURE; } diff --git a/src/util/File.cpp b/src/util/File.cpp index 5a42d2cb9..2142f6c5a 100644 --- a/src/util/File.cpp +++ b/src/util/File.cpp @@ -156,10 +156,10 @@ bool File::fileExtension(string_view path, initializer_list list) /** * Returns file size */ -unsigned long File::fileSize(string_view path) noexcept +unsigned long File::fileSize(const std::filesystem::path &path) noexcept { error_code ec; - auto result = fs::file_size(encodeName(path), ec); + auto result = fs::file_size(path, ec); return ec ? 0 : result; } diff --git a/src/util/File.h b/src/util/File.h index 7177aa6a0..16d06c4e7 100644 --- a/src/util/File.h +++ b/src/util/File.h @@ -42,7 +42,7 @@ namespace digidoc static void updateModifiedTime(const std::string &path, time_t time); static bool fileExists(const std::string& path); static bool fileExtension(std::string_view path, std::initializer_list list); - static unsigned long fileSize(std::string_view path) noexcept; + static unsigned long fileSize(const std::filesystem::path &path) noexcept; static std::string fileName(const std::string& path); static std::string directory(const std::string& path); static std::string path(std::string dir, std::string_view relativePath);