Skip to content

Commit d4fdf5c

Browse files
susnuxskjnldsv
authored andcommitted
fix(installer): ensure valid tempFile & extractDir
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
1 parent c963551 commit d4fdf5c

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

build/psalm-baseline.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2842,9 +2842,6 @@
28422842
<code><![CDATA[$matches[0][$last_match]]]></code>
28432843
<code><![CDATA[$matches[1][$last_match]]]></code>
28442844
</InvalidArrayOffset>
2845-
<InvalidScalarArgument>
2846-
<code><![CDATA[$path]]></code>
2847-
</InvalidScalarArgument>
28482845
<UndefinedInterfaceMethod>
28492846
<code><![CDATA[getQuota]]></code>
28502847
</UndefinedInterfaceMethod>

lib/private/Installer.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,10 @@ public function downloadApp(string $appId, bool $allowUnstable = false): void {
241241

242242
// Download the release
243243
$tempFile = $this->tempManager->getTemporaryFile('.tar.gz');
244+
if ($tempFile === false) {
245+
throw new \RuntimeException('Could not create temporary file for downloading app archive.');
246+
}
247+
244248
$timeout = $this->isCLI ? 0 : 120;
245249
$client = $this->clientService->newClient();
246250
$client->get($app['releases'][0]['download'], ['sink' => $tempFile, 'timeout' => $timeout]);
@@ -252,8 +256,11 @@ public function downloadApp(string $appId, bool $allowUnstable = false): void {
252256
if ($verified === true) {
253257
// Seems to match, let's proceed
254258
$extractDir = $this->tempManager->getTemporaryFolder();
255-
$archive = new TAR($tempFile);
259+
if ($extractDir === false) {
260+
throw new \RuntimeException('Could not create temporary directory for unpacking app.');
261+
}
256262

263+
$archive = new TAR($tempFile);
257264
if (!$archive->extract($extractDir)) {
258265
$errorMessage = 'Could not extract app ' . $appId;
259266

lib/private/legacy/OC_Helper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public static function canExecute($name, $path = false) {
206206
$exts = [''];
207207
$check_fn = 'is_executable';
208208
// Default check will be done with $path directories :
209-
$dirs = explode(PATH_SEPARATOR, $path);
209+
$dirs = explode(PATH_SEPARATOR, (string) $path);
210210
// WARNING : We have to check if open_basedir is enabled :
211211
$obd = OC::$server->get(IniGetWrapper::class)->getString('open_basedir');
212212
if ($obd != 'none') {

0 commit comments

Comments
 (0)