Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent uninitialized $tmpPath when executing unlink(). #88

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
10 changes: 5 additions & 5 deletions h5p.classes.php
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,10 @@ public function __construct($H5PFramework, $H5PCore) {
* TRUE if the .h5p file is valid
*/
public function isValidPackage($skipContent = FALSE, $upgradeOnly = FALSE) {
// Create a temporary dir to extract package in.
$tmpDir = $this->h5pF->getUploadedH5pFolderPath();
$tmpPath = $this->h5pF->getUploadedH5pPath();

// Check dependencies, make sure Zip is present
if (!class_exists('ZipArchive')) {
$this->h5pF->setErrorMessage($this->h5pF->t('Your PHP version does not support ZipArchive.'), 'zip-archive-unsupported');
Expand All @@ -764,10 +768,6 @@ public function isValidPackage($skipContent = FALSE, $upgradeOnly = FALSE) {
return FALSE;
}

// Create a temporary dir to extract package in.
$tmpDir = $this->h5pF->getUploadedH5pFolderPath();
$tmpPath = $this->h5pF->getUploadedH5pPath();

// Only allow files with the .h5p extension:
if (strtolower(substr($tmpPath, -3)) !== 'h5p') {
$this->h5pF->setErrorMessage($this->h5pF->t('The file you uploaded is not a valid HTML5 Package (It does not have the .h5p file extension)'), 'missing-h5p-extension');
Expand Down Expand Up @@ -911,7 +911,7 @@ public function isValidPackage($skipContent = FALSE, $upgradeOnly = FALSE) {
// This is a breaking error, there's no need to continue. (the rest of the files will fail as well)
$this->h5pF->setErrorMessage($this->h5pF->t('Unable to read file from the package: %fileName', array('%fileName' => $fileName)), 'unable-to-read-package-file');
$zip->close();
unlink($path);
unlink($tmpPath);
H5PCore::deleteFileTree($tmpDir);
return FALSE;
}
Expand Down