Catch some invalid parameter (may come from damaged file) and throw exception. (#39)

Signed-off-by: Roland Häder <roland@mxchange.org>
This commit is contained in:
Roland Haeder 2016-11-16 14:17:43 +01:00 committed by Adrien Crivelli
parent 3cc80bd874
commit 4b4831be07
1 changed files with 8 additions and 0 deletions

View File

@ -302,6 +302,14 @@ class OLERead
*/
private static function getInt4d($data, $pos)
{
if (trim($data) == '') {
// No data provided
throw new \PhpOffice\PhpSpreadsheet\Reader\Exception('Parameter data is empty.');
} elseif ($pos < 0) {
// Invalid position
throw new \PhpOffice\PhpSpreadsheet\Reader\Exception('Parameter pos=' . $pos . ' is invalid.');
}
$len = strlen($data);
if ($len < $pos + 4) {
$data .= str_repeat("\0", $pos + 4 - $len);