Skip to content
This repository has been archived by the owner on Jan 2, 2019. It is now read-only.

Throw InvalidArgumentException in case getint4d fails #878

Open
wants to merge 2 commits into
base: 1.8
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions Classes/PHPExcel/Shared/OLERead.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,34 @@ private static function getInt4d($data, $pos)
// FIX: represent numbers correctly on 64-bit system
// http://sourceforge.net/tracker/index.php?func=detail&aid=1487372&group_id=99160&atid=623334
// Hacked by Andreas Rehm 2006 to ensure correct result of the <<24 block on 32 and 64bit systems

// Handling Errors : Dependancy of code on $pos of $data. Hence added a check to make sure the block is valid/readable.
// Throwing Exception incase of any error.

if (!isset($data[$pos + 3])) {
//String $error_message : Declaration only once
$error_message = 'EXCEPTION (InvalidBlockException) :: CORRUPT BLOCKS IN XLS FILE'."\nCallStack:\n";

foreach (debug_backtrace() as $arr_info_element) {
//String $message : Redeclaration
$message = '';

foreach ($arr_info_element as $info_property => $info_value) {
// ignoring the properties [object], [args] and [type] as it causes essay effect while printing error message.
if ($info_property == 'object' || $info_property == 'args' || $info_property == 'type') {
continue;
}

$message .= $info_property.'=>['.$info_value.'] ';
}

//add error message
if (!empty($message)) {
$error_message .= $message."\n";
}
}
throw new InvalidArgumentException($error_message);
}
$_or_24 = ord($data[$pos + 3]);
if ($_or_24 >= 128) {
// negative number
Expand Down