Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2016-12-09 19:46:05 +0300
committerLukas Reschke <lukas@statuscode.ch>2016-12-09 20:01:45 +0300
commit32bf8ec826dadbfd342627884fbdf83081db9b29 (patch)
treecdaa5a962fc20203a8a3143f5e30674b8b5d77fb /lib
parent0de83a3a0189a96338abd0345b70c89bc543bf49 (diff)
Don't use cached informations for app version
When installing an app from the appstore the `\OC_App::getAppVersion` code is triggered twice: - First when the downloader tries to compare the current version to the new version on the appstore to check if there is a newer version. This protects against downgrade attacks and is implemented in `\OC\Installer::downloadApp`. - Second, when the app is actually installed the current version is written to the database. (`\OC\Installer::installApp`) This fails however when the version is actually cached. Because in step 1 the cached version will be set to "0" and then be reused in the second step. While this is probably not the cleanest version I assume this is an approach that is least invasive. Feedback and suggestions welcome :) Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Installer.php2
-rw-r--r--lib/private/legacy/app.php11
2 files changed, 8 insertions, 5 deletions
diff --git a/lib/private/Installer.php b/lib/private/Installer.php
index db71f7b1432..38d0ce13684 100644
--- a/lib/private/Installer.php
+++ b/lib/private/Installer.php
@@ -121,7 +121,7 @@ class Installer {
OC_App::executeRepairSteps($appId, $appData['repair-steps']['install']);
//set the installed version
- \OC::$server->getConfig()->setAppValue($info['id'], 'installed_version', OC_App::getAppVersion($info['id']));
+ \OC::$server->getConfig()->setAppValue($info['id'], 'installed_version', OC_App::getAppVersion($info['id'], false));
\OC::$server->getConfig()->setAppValue($info['id'], 'enabled', 'no');
//set remote/public handlers
diff --git a/lib/private/legacy/app.php b/lib/private/legacy/app.php
index 0d9adfa9d2b..adf29601ac6 100644
--- a/lib/private/legacy/app.php
+++ b/lib/private/legacy/app.php
@@ -653,13 +653,16 @@ class OC_App {
* get the last version of the app from appinfo/info.xml
*
* @param string $appId
+ * @param bool $useCache
* @return string
*/
- public static function getAppVersion($appId) {
- if (!isset(self::$appVersion[$appId])) {
- $file = self::getAppPath($appId);
- self::$appVersion[$appId] = ($file !== false) ? self::getAppVersionByPath($file) : '0';
+ public static function getAppVersion($appId, $useCache = true) {
+ if($useCache && isset(self::$appVersion[$appId])) {
+ return self::$appVersion[$appId];
}
+
+ $file = self::getAppPath($appId);
+ self::$appVersion[$appId] = ($file !== false) ? self::getAppVersionByPath($file) : '0';
return self::$appVersion[$appId];
}