Issue Bug Closed

#103943is_dir() check with trailing slash violates open_basedir restriction if node is a file

Benjamin Franzke 05/28/24, 10:20 updated 07/09/24, 15:35

Description

If a folder is tried to be created where currently a file is located, the following open_basedir warning is emitted:

PHP Warning: is_dir(): open_basedir restriction in effect. File(/srv/vhosts/…/site/mage/releases/…/public/fileadmin/…/) is not within the allowed path(s): (/srv/vhosts/…/site/:/usr/share/php/:/tmp/:/usr/bin/:/bin/:/usr/local/bin/:/usr/local/lib/) in /srv/vhosts/…/site/mage/releases/…/public/typo3/sysext/core/Classes/Utility/GeneralUtility.php line 1920

This can be verified via:

<?php
file_put_contents('foobar', '');
ini_set('open_basedir', __DIR__);
// OK
var_dump(is_file(__DIR__ . '/foobar'));
// OK
var_dump(is_dir(__DIR__ . '/foobar'));
// Not OK, warning
var_dump(is_dir(__DIR__ . '/foobar/'));

Reviews 3

History 25

  1. Gerrit Code Review pushed patch set 1 for 11.5 to change 84437 status New Under Review 05/28/24, 10:23

  2. Gerrit Code Review pushed patch set 1 for main to change 84452 05/28/24, 10:25

  3. Gerrit Code Review pushed patch set 1 for 12.4 to change 84461 06/05/24, 14:50

  4. Benjamin Franzke commented and changed status Under Review Resolved done 0 % 100 % 06/05/24, 15:05

    Applied in changeset commit:cef0b7d187ef8c4026abf826316a2e85596e76c7.

  5. Benni Mack changed status Resolved Closed 07/09/24, 15:35