Ror() & Rol() bugged on Linux

Report any Hollywood bugs here
Post Reply
User avatar
Allanon
Posts: 653
Joined: Sun Feb 14, 2010 7:53 pm
Location: Italy
Contact:

Ror() & Rol() bugged on Linux

Post by Allanon »

Hello Andreas,
I took me 2 days to identify why my encryption routines worked on Windows but not on Linux (Linux Mint 9, x64).
Finally I've found a small script that demonstrate the bug:

Code: Select all

Local a = 72
Local b = 111
Local c = Ror(a, b, #BYTE)
DebugPrint(a .. " ror " .. b .. " = " .. c)
DebugPrompt("?")
Run on Windows and you get:

Code: Select all

72 ror 111 = 144
?
Compile and run on Linux and you get:

Code: Select all

72 ror 111 = 0
?
btw setting 'b' with a smaller value (for example 5) it works the same way on both Windows & Linux
----------------------------
[Allanon] Fabio Falcucci
AMC - Creative Development // Docs Site // Support Forum
Support me on Patreon for Hollywood libraries!

User avatar
airsoftsoftwair
Posts: 4606
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Ror() & Rol() bugged on Linux

Post by airsoftsoftwair »

Thanks for the report, fixed now!

Code: Select all

- Fix: Ror() and Rol() didn't return correct results when the rotation count was greater than the rotation bit length 
As a workaround, just make sure the rotation cycle count is not bigger than rotation bit length by applying a modulo division first, e.g.

Code: Select all

Local a = 72
Local b = 111
Local c = Ror(a, b%8, #BYTE)
DebugPrint(a .. " ror " .. b .. " = " .. c)
DebugPrompt("?")

User avatar
Allanon
Posts: 653
Joined: Sun Feb 14, 2010 7:53 pm
Location: Italy
Contact:

Re: Ror() & Rol() bugged on Linux

Post by Allanon »

Thank you!
:)
----------------------------
[Allanon] Fabio Falcucci
AMC - Creative Development // Docs Site // Support Forum
Support me on Patreon for Hollywood libraries!

Post Reply