PHP Excel/Reader and oleread.inc not reading negative numbers on 64-bit machines
I recently switched from a 32-bit machine to a 64-bit machine. I noticed that negative numbers were coming in around 1073741814. This has to do with how bits are shifted on the different machines.
I have read that not patching these files will cause memory exhaustion, which can be critically bad in a production environment.
I found a fix for oleread.inc that replace the GetInt4d function with
function GetInt4d($data, $pos) {
$_or_24 = ord($data[$pos+3]);
if ($_or_24>=128)
$_ord_24 = -abs((256-$_or_24) << 24);
else
$_ord_24 = ($_or_24&127) << 24;
return ord($data[$pos]) | (ord($data[$pos+1]) <<
| (ord($data[$pos+2]) << 16) | $_ord_24;
}
But what they failed to mention was that you also have to change the function _GetInt4d in the Excel/reader.php file as well.
I hope this helps someone (or myself) in the future.

























You must be logged in to post a comment.