From f4a208915ef1e0e7d6eee72653d04c52cf7b261f Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 2 Mar 2022 11:44:57 +0100 Subject: [PATCH] [HttpKernel] Guard against bad profile data --- .../HttpKernel/Profiler/FileProfilerStorage.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php b/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php index 1ef58dc74cb92..d729994c1f0cc 100644 --- a/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php +++ b/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php @@ -123,7 +123,11 @@ public function read($token): ?Profile $file = 'compress.zlib://'.$file; } - return $this->createProfileFromData($token, unserialize(file_get_contents($file))); + if (!$data = unserialize(file_get_contents($file))) { + return null; + } + + return $this->createProfileFromData($token, $data); } /** @@ -297,7 +301,11 @@ protected function createProfileFromData($token, $data, $parent = null) $file = 'compress.zlib://'.$file; } - $profile->addChild($this->createProfileFromData($token, unserialize(file_get_contents($file)), $profile)); + if (!$childData = unserialize(file_get_contents($file))) { + continue; + } + + $profile->addChild($this->createProfileFromData($token, $childData, $profile)); } return $profile;