From c2659242f4033e68ba5fcfc606df46e1059fa616 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 --- Profiler/FileProfilerStorage.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Profiler/FileProfilerStorage.php b/Profiler/FileProfilerStorage.php index 1ef58dc74c..d729994c1f 100644 --- a/Profiler/FileProfilerStorage.php +++ b/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;