Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion src/ASiC_S.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ ASiC_S::ASiC_S(const string &path)
string tst = z.extract<stringstream>(uri).str();
addSignature(make_unique<SignatureTST>(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");
}
Expand Down
5 changes: 3 additions & 2 deletions src/ASiContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<istream> is = make_unique<ifstream>(File::encodeName(path), ifstream::binary);
unique_ptr<istream> is = make_unique<ifstream>(nativePath, ifstream::binary);
if(!*is)
THROW("Failed to open file for reading: %s.", path.c_str());
if(size <= MAX_MEM_FILE)
Expand Down
2 changes: 1 addition & 1 deletion src/SignatureTST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void SignatureTST::validate() const
string_view method = (ref/DigestMethod)["Algorithm"];
auto uri = util::File::fromUriPath(ref["URI"]);
vector<unsigned char> digest = file->fileName() == uri ?
dynamic_cast<const DataFilePrivate*>(file)->calcDigest(string(method)) :
static_cast<const DataFilePrivate*>(file)->calcDigest(string(method)) :
asicSDoc->fileDigest(uri, method).result();
if(vector<unsigned char> digestValue = ref/DigestValue; digest != digestValue)
THROW("Reference %s digest does not match", uri.c_str());
Expand Down
8 changes: 6 additions & 2 deletions src/XMLDocument.h
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ struct XMLDocument: public unique_free_d<xmlFreeDoc>, 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);
Expand All @@ -469,15 +469,19 @@ struct XMLDocument: public unique_free_d<xmlFreeDoc>, 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());
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/XmlConf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions src/digidoc-tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
4 changes: 2 additions & 2 deletions src/util/File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,10 @@ bool File::fileExtension(string_view path, initializer_list<string_view> 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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/util/File.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string_view> 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);
Expand Down