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

make sure that parameters are a string when string is expected #40944

Merged
merged 1 commit into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion apps/dav/lib/Connector/Sabre/ServerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function createServer(
$config = $this->config;

$server->on('beforeMethod:PROPFIND', function (Request $request) use ($config) {
$depthHeader = strtolower($request->getHeader('depth'));
$depthHeader = strtolower($request->getHeader('depth') ?? '');

if ($depthHeader === 'infinity' && !$config->getSystemValue('dav.propfind.depth_infinity', false)) {
throw new PreconditionFailed('Depth infinity not supported');
Expand Down
6 changes: 6 additions & 0 deletions changelog/unreleased/40944
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: make sure that parameters are a string when string is expected

The code now checks for when variables are null are passed to functions that
expect a string, and handles that correctly.

https://github.com/owncloud/core/pull/40944
2 changes: 1 addition & 1 deletion lib/private/AppFramework/Http/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ protected function decodeContent() {
$params = [];

// 'application/json' must be decoded manually.
if (\strpos($this->getHeader('Content-Type'), 'application/json') !== false) {
if (\strpos($this->getHeader('Content-Type') ?? '', 'application/json') !== false) {
$params = \json_decode(\file_get_contents($this->inputStream), true);
if (\is_array($params) && \count($params) > 0) {
$this->items['params'] = $params;
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Security/Crypto.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function decrypt($authenticatedCiphertext, $password = '') {
$password = $this->config->getSystemValue('secret');
}

$parts = \explode('|', $authenticatedCiphertext);
$parts = \explode('|', $authenticatedCiphertext ?? '');

// v2 uses stronger binary random iv
if (\sizeof($parts) === 4 && $parts[0] === 'v2') {
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Setup/AbstractDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function initialize($config) {
$dbUser = $config['dbuser'];
$dbPass = $config['dbpass'];
$dbName = $config['dbname'];
$dbConnectionString = $config['dbconnectionstring'];
$dbConnectionString = $config['dbconnectionstring'] ?? '';
$dbHost = !empty($config['dbhost']) ? $config['dbhost'] : 'localhost';
$dbTablePrefix = isset($config['dbtableprefix']) ? $config['dbtableprefix'] : 'oc_';

Expand Down
6 changes: 5 additions & 1 deletion lib/private/User/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,11 @@ public function setNewRememberMeTokenForLoggedInUser() {
public function clearRememberMeTokensForLoggedInUser($targetToken) {
$user = $this->getUser();
$uid = $user->getUID();
$hashedToken = \hash('snefru', $targetToken);
if ($targetToken !== null) {
$hashedToken = \hash('snefru', $targetToken);
} else {
$hashedToken = "";
}

$keys = $this->config->getUserKeys($uid, 'login_token');
foreach ($keys as $key) {
Expand Down
2 changes: 1 addition & 1 deletion lib/private/legacy/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ public static function is_function_enabled($function_name) {
if (\in_array($function_name, $disabled)) {
return false;
}
$disabled = \explode(',', $ini->get('suhosin.executor.func.blacklist'));
$disabled = \explode(',', $ini->get('suhosin.executor.func.blacklist') ?? '');
$disabled = \array_map('trim', $disabled);
if (\in_array($function_name, $disabled)) {
return false;
Expand Down