OneSourceCat / phpvulhunter

A tool that can scan php vulnerabilities automatically using static analysis methods
486 stars 128 forks source link

break is not in loop or case context in CFGGenerator.php on line 923 #3

Open lilmike opened 7 years ago

lilmike commented 7 years ago

Basically what it says, CFGGenerator.php, line 923, that's the error I get when going to my website (localhost) /phpvulhunter/main.php. I'm running nginx 1.11.5, php 7.0.13 (php-fpm 7.0.13). -Michael.

oxblue-rbollig commented 6 years ago

Am able to reproduce.

[Thu Sep 28 17:01:08.410085 2017] [:error] [pid 1542] [client 192.168.1.91:46458] PHP Fatal error: 'break' not in the 'loop' or 'switch' context in /var/www/html/phpvulhunter/CFGGenerator.php on line 923

PHP 7.0.22-0ubuntu0.16.04.1 (cli) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies with Zend OPcache v7.0.22-0ubuntu0.16.04.1, Copyright (c) 1999-2017, by Zend Technologies root@ubuntu:/var/www/html#

derricksmith commented 6 years ago

PHP7 no longer allows break outside of of switch or loop.

Replace:

if(!$funcBody) break ; $cfg = new CFGGenerator() ; //$this->block->function[$nodeName] $arr = $this->sinkContext->getAllSinks() ; $arr = $arr[$nodeName] ; foreach ($arr as $pos){ $argName = NodeUtils::getNodeFuncParams($node); $argName = $argName[$pos] ; $this->vars = $this->sinkMultiBlockTraceback($argName, $this->block,0);
}

With:

if(!$funcBody){ $cfg = new CFGGenerator() ; //$this->block->function[$nodeName] $arr = $this->sinkContext->getAllSinks() ; $arr = $arr[$nodeName] ; foreach ($arr as $pos){ $argName = NodeUtils::getNodeFuncParams($node); $argName = $argName[$pos] ; $this->vars = $this->sinkMultiBlockTraceback($argName, $this->block,0);
} }