Bug Tracker – Bug 953

ACS interpreter assumes little endian, not good for non-x86 (p_acs.cpp)

Last modified: 2016-11-11 23:03:41 CST
Bug 953 - (ARRAY(0x4975608)) ACS interpreter assumes little endian, not good for non-x86 (p_acs.cpp)
(ARRAY(0x4975608))
ACS interpreter assumes little endian, not good for non-x86 (p_acs.cpp)
Status: ASSIGNED
Product: Odamex
Classification: Unclassified
Component: Server & Client
0.6.x
PPC (Mac, AIX, Solaris) All
: P1 trivial
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2013-02-22 20:30:38 CST by GhostlyDeath
Modified: 2016-11-11 23:03 CST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description GhostlyDeath 2013-02-22 20:30:38 CST
I'll keep this short, the entirety of the ACS code located within p_acs.cpp must be rewritten or have its problems corrected, whichever might be easier. This is on PowerPC systems, but this WILL affect all other big endian systems and other systems with alignment requirements where the compiler is too dumb to do slower unaligned reads.

Stuff like: 
	Scripts = object + ((DWORD *)object)[1];
	NumScripts = ((DWORD *)Scripts)[0];

The problems with the code:
 * Assumes the de-referenced DWORDs are of the same byte order, which they are not (they are in little endian).
 * Assumes that the addresses are aligned, which they might not always be.
 * int is used in some cases, which might not always be 32-bit.

Stuff to be cautious about:
 * DWORD better be uint32_t or int32_t

These problems are littered all over the entire file.
Comment 1 Mike Lightner 2013-02-22 20:54:06 CST
Thank you for your report.  I have updated the summary to better reflect the nature of the issue.
Comment 2 Ralph Vickers 2016-11-11 23:03:41 CST
Reduced to trivial