summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2017-04-24 23:57:22 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2017-05-19 03:43:30 +0200
commit3e4f3ac9368f1cdb3176cf656bf881e961fa67d5 (patch)
tree695d749576bc15ecf793cfe7eb5bc009dfaa7f2e /desktop
parent8eda8fa69c0ce06c07f1f3c0ca3fccacbe915703 (diff)
actually abort the update process if the update file is invalid
Change-Id: I724e50d1e74228f0be00b9b6376c3d074db5c9ed
Diffstat (limited to 'desktop')
-rw-r--r--desktop/source/app/updater.cxx44
1 files changed, 44 insertions, 0 deletions
diff --git a/desktop/source/app/updater.cxx b/desktop/source/app/updater.cxx
index 1d3b0acc9158..cad36200daaa 100644
--- a/desktop/source/app/updater.cxx
+++ b/desktop/source/app/updater.cxx
@@ -287,6 +287,40 @@ class invalid_update_info : public std::exception
{
};
+class invalid_hash : public std::exception
+{
+ OString maMessage;
+public:
+
+ invalid_hash(const OUString& rExpectedHash, const OUString& rReceivedHash)
+ {
+ OUString aMsg = "Invalid hash found.\nExpected: " + rExpectedHash + ";\nReceived: " + rReceivedHash;
+ maMessage = OUStringToOString(aMsg, RTL_TEXTENCODING_UTF8);
+ }
+
+ const char* what() const noexcept override
+ {
+ return maMessage.getStr();
+ }
+};
+
+class invalid_size : public std::exception
+{
+ OString maMessage;
+public:
+
+ invalid_size(const size_t nExpectedSize, const size_t nReceivedSize)
+ {
+ OUString aMsg = "Invalid file size found.\nExpected: " + OUString::number(nExpectedSize) + ";\nReceived: " + OUString::number(nReceivedSize);
+ maMessage = OUStringToOString(aMsg, RTL_TEXTENCODING_UTF8);
+ }
+
+ const char* what() const noexcept override
+ {
+ return maMessage.getStr();
+ }
+};
+
OUString toOUString(const std::string& rStr)
{
return OUString::fromUtf8(rStr.c_str());
@@ -538,11 +572,13 @@ void download_file(const OUString& rURL, size_t nFileSize, const OUString& rHash
if (nSize != nFileSize)
{
SAL_WARN("desktop.updater", "File sizes don't match. File might be corrupted.");
+ throw invalid_size(nFileSize, nSize);
}
if (aHash != rHash)
{
SAL_WARN("desktop.updater", "File hash don't match. File might be corrupted.");
+ throw invalid_hash(rHash, aHash);
}
OUString aPatchDirURL("${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE("bootstrap") ":UserInstallation}/patch/");
@@ -600,6 +636,14 @@ void update_checker()
{
SAL_WARN("desktop.updater", "error during the update check");
}
+ catch (const invalid_size& e)
+ {
+ SAL_WARN("desktop.updater", e.what());
+ }
+ catch (const invalid_hash& e)
+ {
+ SAL_WARN("desktop.updater", e.what());
+ }
catch (...)
{
SAL_WARN("desktop.updater", "unknown error during the update check");