Skip to content

Commit

Permalink
[BUGFIX] Prevent undefined array index in GifBuilder
Browse files Browse the repository at this point in the history
Unset non matching key arrays and additionally
secure the array access with a corresponding
check.

Resolves: #102241
Releases: main, 12.4
Change-Id: If034faf04f52f6e8882dd0b610fa5dfdf9ec2298
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/83570
Reviewed-by: Oliver Bartsch <bo@cedev.de>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Oliver Bartsch <bo@cedev.de>
  • Loading branch information
o-ba committed Mar 22, 2024
1 parent 77077a6 commit 5014c8c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions typo3/sysext/frontend/Classes/Imaging/GifBuilder.php
Expand Up @@ -159,8 +159,10 @@ public function start($conf, $data)
}
// Checking TEXT and IMAGE objects for files. If any errors the objects are cleared.
// The Bounding Box for the objects is stored in an array
foreach ($sKeyArray as $theKey) {
$theValue = $this->setup[$theKey];
foreach ($sKeyArray as $index => $theKey) {
if (!($theValue = $this->setup[$theKey] ?? false)) {
continue;
}
if ((int)$theKey && ($conf = $this->setup[$theKey . '.'] ?? [])) {
// Swipes through TEXT and IMAGE-objects
switch ($theValue) {
Expand Down Expand Up @@ -228,6 +230,7 @@ public function start($conf, $data)
$cObj = GeneralUtility::makeInstance(ContentObjectRenderer::class);
$cObj->start($this->data);
if (!$cObj->checkIf($conf['if.'])) {
unset($sKeyArray[$index]);
unset($this->setup[$theKey]);
unset($this->setup[$theKey . '.']);
unset($this->objBB[$theKey]);
Expand All @@ -242,7 +245,9 @@ public function start($conf, $data)
$this->setup['workArea'] = (string)$this->cObj->stdWrapValue('workArea', $this->setup ?? []);
$this->setup['workArea'] = $this->calcOffset($this->setup['workArea']);
foreach ($sKeyArray as $theKey) {
$theValue = $this->setup[$theKey];
if (!($theValue = $this->setup[$theKey] ?? false)) {
continue;
}
if ((int)$theKey && ($this->setup[$theKey . '.'] ?? false)) {
switch ($theValue) {
case 'TEXT':
Expand Down

0 comments on commit 5014c8c

Please sign in to comment.