Menu

#39 AMD64 dead loop fix

open
nobody
None
5
2006-05-12
2006-05-12
No

Hi there!

Your oleread.inc is not 64bit safe!

Your function GetInt4d does not act correctly. It
should do something equal to an addition but it uses
bitshift. The bitshift behaves different on a 64bit
enabled system. First bit is always the signum.

The function GetInt4d should be replaced with something
like this:

function GetInt4d($data, $pos) {
// Hacked by Andreas Rehm 2006 to ensure correct
result of the <<24 block on 32 and 64bit systems
$_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]) << 8) |
(ord($data[$pos+2]) << 16) | $_ord_24;
}

Regards,
Andreas Rehm

Discussion

  • Jarno Elonen

    Jarno Elonen - 2006-05-25

    Logged In: YES
    user_id=312071

    I also hit my head to this after moving my pages to a new
    ISP. This fix seems to work OK, as well as the one for the
    E_NOTICE bug. A bug-fix release would be really welcome,
    even if it only consisted of these two patches.

     
  • Nobody/Anonymous

    Logged In: NO

    I've tested and that seems to correct the problem . Good job !

    Thx,
    Alexandre FERAUD

     
  • Nobody/Anonymous

    Logged In: NO

    Andreas Rehm,

    You are a lifesaver..

    ElCamino

     
  • Nobody/Anonymous

    Logged In: NO

    Thanks. Been tearing my hair out for 2 hours over what might
    be causing this. I had no idea the server in question was
    64bit. You're a lifesaver.

     
  • Nobody/Anonymous

    Logged In: NO

    +1

     

Log in to post a comment.