From dff5e3c54296e2ccc3d403cec9f31ecd2aafca9f Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 14 Nov 2013 21:21:08 +0100 Subject: [PATCH] Fail hard if anything attempts to wipe the entire filesystem/partition, fixes #2409 --- src/Composer/Util/Filesystem.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Composer/Util/Filesystem.php b/src/Composer/Util/Filesystem.php index 2e18eb71e..8771776fc 100644 --- a/src/Composer/Util/Filesystem.php +++ b/src/Composer/Util/Filesystem.php @@ -69,6 +69,10 @@ class Filesystem return true; } + if (preg_match('{^(?:[a-z]:)?[/\\\\]+$}i', $directory)) { + throw new \RuntimeException('Aborting an attempted deletion of '.$directory.', this was probably not intended, if it is a real use case please report it.'); + } + if (!function_exists('proc_open')) { return $this->removeDirectoryPhp($directory); }