diff options
author | Robin Appelman <icewind@owncloud.com> | 2014-08-14 15:47:23 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2014-08-31 10:45:11 +0200 |
commit | dcc4f96d3e368ee976cd085c18dcb74ada3617ce (patch) | |
tree | 267b8bbf66ec4cc3b1201c4a3f6229f24b1df9fb | |
parent | c2ebc192a6a6c7cb9cff958e412e0cc4aff15ead (diff) | |
download | nextcloud-server-dcc4f96d3e368ee976cd085c18dcb74ada3617ce.tar.gz nextcloud-server-dcc4f96d3e368ee976cd085c18dcb74ada3617ce.zip |
Verify names of certificates
-rw-r--r-- | apps/files_external/ajax/removeRootCertificate.php | 4 | ||||
-rw-r--r-- | lib/private/certificatemanager.php | 11 |
2 files changed, 11 insertions, 4 deletions
diff --git a/apps/files_external/ajax/removeRootCertificate.php b/apps/files_external/ajax/removeRootCertificate.php index e6795800e03..0931138ad4b 100644 --- a/apps/files_external/ajax/removeRootCertificate.php +++ b/apps/files_external/ajax/removeRootCertificate.php @@ -6,6 +6,4 @@ OCP\JSON::callCheck(); $name = $_POST['cert']; $certificateManager = \OC::$server->getCertificateManager(); -if (\OC\Files\Filesystem::isValidPath($name)) { - $certificateManager->removeCertificate($name); -} +$certificateManager->removeCertificate($name); diff --git a/lib/private/certificatemanager.php b/lib/private/certificatemanager.php index 72e0541fa40..e07413c127f 100644 --- a/lib/private/certificatemanager.php +++ b/lib/private/certificatemanager.php @@ -8,10 +8,12 @@ namespace OC; +use OCP\ICertificateManager; + /** * Manage trusted certificates for users */ -class CertificateManager { +class CertificateManager implements ICertificateManager { /** * @var \OCP\IUser */ @@ -76,6 +78,9 @@ class CertificateManager { * @return bool */ public function addCertificate($certificate, $name) { + if (!\OC\Files\Filesystem::isValidPath($name)) { + return false; + } $isValid = openssl_pkey_get_public($certificate); if (!$isValid) { @@ -96,8 +101,12 @@ class CertificateManager { /** * @param string $name + * @return bool */ public function removeCertificate($name) { + if (!\OC\Files\Filesystem::isValidPath($name)) { + return false; + } $path = $this->user->getHome() . '/files_external/uploads/'; if (file_exists($path . $name)) { unlink($path . $name); |