FileSystem::mkdir generates SegFault on empty dir

Created on 5 June 2024, 6 months ago

Problem/Motivation

FileSystem::mkdir allows to be called with an empty string as first argument, hence it tries to create it recursively and generate a segmentation fault.

Steps to reproduce

drush ev '$f = Drupal::service("file_system");$dir="";var_dump($f->mkdir($dir, 1));'
Segmentation fault

# Adding xdebug trace generate à 1.3GB trace file mostly filed with the infinite recursion 
php -dxdebug.mode=trace -dxdebug.start_with_request=yes drush ev '$f = Drupal::service("file_system");$dir="";var_dump($f->mkdir($dir, 1));'

Proposed resolution

FileSystemInterface::prepareDirectory should check if the input is a valid directory name, StreamWrapperManagerInterface::isValidUri is not enough.

Remaining tasks

  1. Add a check
  2. Update method and parameter comments
  3. Update the tests

User interface changes

none

API changes

Update documentation

Data model changes

none

Release notes snippet

none

🐛 Bug report
Status

Closed: works as designed

Version

10.4

Component
File system 

Last updated about 11 hours ago

Created by

🇫🇷France O'Briat Nantes

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024