sabberworm / PHP-CSS-Parser

A Parser for CSS Files written in PHP. Allows extraction of CSS files into a data structure, manipulation of said structure and output as (optimized) CSS

Home Page:http://www.sabberworm.com/blog/2010/6/10/php-css-parser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Infinite loop on malformed input

nikic opened this issue · comments

When trying to parse the input P{P:[, the parser goes into an infinite loop.

Backtrace snapshot:

#1 /home/nikic/PHP-Fuzzer/example/PHP-CSS-Parser/lib/Sabberworm/CSS/Parsing/ParserState.php(52): Sabberworm\CSS\Parsing\ParserState->parseCharacter(true)
#2 /home/nikic/PHP-Fuzzer/example/PHP-CSS-Parser/lib/Sabberworm/CSS/Value/LineName.php(20): Sabberworm\CSS\Parsing\ParserState->parseIdentifier()
#3 /home/nikic/PHP-Fuzzer/example/PHP-CSS-Parser/lib/Sabberworm/CSS/Value/Value.php(94): Sabberworm\CSS\Value\LineName::parse(Object(Sabberworm\CSS\Parsing\ParserState))
#4 /home/nikic/PHP-Fuzzer/example/PHP-CSS-Parser/lib/Sabberworm/CSS/Value/Value.php(36): Sabberworm\CSS\Value\Value::parsePrimitiveValue(Object(Sabberworm\CSS\Parsing\ParserState))
#5 /home/nikic/PHP-Fuzzer/example/PHP-CSS-Parser/lib/Sabberworm/CSS/Rule/Rule.php(39): Sabberworm\CSS\Value\Value::parseValue(Object(Sabberworm\CSS\Parsing\ParserState), Array)
#6 /home/nikic/PHP-Fuzzer/example/PHP-CSS-Parser/lib/Sabberworm/CSS/RuleSet/RuleSet.php(35): Sabberworm\CSS\Rule\Rule::parse(Object(Sabberworm\CSS\Parsing\ParserState))
#7 /home/nikic/PHP-Fuzzer/example/PHP-CSS-Parser/lib/Sabberworm/CSS/RuleSet/DeclarationBlock.php(62): Sabberworm\CSS\RuleSet\RuleSet::parseRuleSet(Object(Sabberworm\CSS\Parsing\ParserState), Object(Sabberworm\CSS\RuleSet\DeclarationBlock))
#8 /home/nikic/PHP-Fuzzer/example/PHP-CSS-Parser/lib/Sabberworm/CSS/CSSList/CSSList.php(101): Sabberworm\CSS\RuleSet\DeclarationBlock::parse(Object(Sabberworm\CSS\Parsing\ParserState), Object(Sabberworm\CSS\CSSList\Document))
#9 /home/nikic/PHP-Fuzzer/example/PHP-CSS-Parser/lib/Sabberworm/CSS/CSSList/CSSList.php(50): Sabberworm\CSS\CSSList\CSSList::parseListItem(Object(Sabberworm\CSS\Parsing\ParserState), Object(Sabberworm\CSS\CSSList\Document))
#10 /home/nikic/PHP-Fuzzer/example/PHP-CSS-Parser/lib/Sabberworm/CSS/CSSList/Document.php(21): Sabberworm\CSS\CSSList\CSSList::parseList(Object(Sabberworm\CSS\Parsing\ParserState), Object(Sabberworm\CSS\CSSList\Document))
#11 /home/nikic/PHP-Fuzzer/example/PHP-CSS-Parser/lib/Sabberworm/CSS/Parser.php(38): Sabberworm\CSS\CSSList\Document::parse(Object(Sabberworm\CSS\Parsing\ParserState))
#12 /home/nikic/PHP-Fuzzer/example/target_css_parser.php(9): Sabberworm\CSS\Parser->parse()
ezoic increase your site revenue