#64 Endianness issues on PowerPC

open
nobody
None
9
2008-07-17
2008-07-17
No

I found some issues with PHP-ExcelReader on a Power PC server with an Excel file containing cells with date format. The conversion would block indefinitely with 100% CPU usage at this line:

$string = date ($this->curformat, $utcValue);

in function "createDate($numValue)" of reader.php. The problem was that the value of $numValue was ridiculously high and it was probably overflowing the date function, putting it in an infinite loop. The problem came from this conversion:

$tmp = unpack("ddouble", substr($this->data, $spos + 6, 8));

The value is stored in little-endian format in the Excel file but it was read as a big-endian binary format on PowerPC.

I added to reader.php a small test to detect the endianness of the host hardware and I reverse the value returned by "substr($this->data, $spos + 6, 8)", using "strrev()" if PHP-ExcelReader is executed on a big-endian host. I included a patch to solve the problem on "reader.php".

Discussion

  • Gabriel Lavoie

    Gabriel Lavoie - 2008-07-17

    Patch to detect the endianness of the host.

     
    Attachments
  • Gabriel Lavoie

    Gabriel Lavoie - 2008-07-17
    • priority: 5 --> 9
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks