Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$depth variable is not used, hence getPrevious method could end up in infinite loop #1726

Closed
AidasK opened this issue Jul 7, 2022 · 0 comments
Labels
Milestone

Comments

@AidasK
Copy link

AidasK commented Jul 7, 2022

Monolog version 3.1.0

https://github.com/Seldaek/monolog/blob/main/src/Monolog/Formatter/LineFormatter.php#L153

$depth variable is not used, hence getPrevious method could end up in infinite loop:

            do {
                $str .= "\n[previous exception] " . $this->formatException($previous);
            } while ($previous = $previous->getPrevious());

This could be changed to:

            do {
                if ($depth++ > $this->maxNormalizeDepth) {
                    $str .= 'Over ' . $this->maxNormalizeDepth . ' levels deep, aborting normalization';
                    break;
                }
                $str .= "\n[previous exception] " . $this->formatException($previous);
            } while (($previous = $previous->getPrevious()));
@AidasK AidasK added the Bug label Jul 7, 2022
@Seldaek Seldaek added this to the 2.x milestone Jul 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants