The UNP64 code was not endian safe, unaligned and contained a couple of
out-of-bounds reads and errors in the translation to C++.
This fixes that, mainly by adding a number of helper functions to
exo_util.cpp and replacing the unsafe code with calls to them.
Parts of the code of Unp64 comes from Exomizer, a tool which uses
as modified Zlib license which is not compatible with GPL. The author of
Exomizer, Magnus Lind, has given permission to distribute this code under
unmodified Zlib license, so I have updated that here.
(The author of Unp64, iAN CooG, has agreed to let us distribute his code
under a GPL license. Or any license we want, to be precise.)
If nv or nn (number of verbs or number of nouns) is equal to or larger than the number
of words + 2, this loop will try to write out of bounds and assert. This happens for
example in the C64 version of The Golden Baton.
To fix this, it is really enough to change the >= operator to >, but I took the opportunity
to simplify the code a bit as well.
The method diCreateFromData() is set up as if it is going to copy the
data supplied by the caller to the _image member, allocating memory for
it, but then just assigns the data to it instead, leaking the allocated
memory.
This also means that if the data supplied is not a valid disk image, it
will delete the original data in the default case.
We fix this by just removing the allocation and the deletion. An
alternative would have been to actually copy the data instead.
Avoid picking any .d64 (Commodore disc) or .t64 (Commodore tape)
as a possible Scott game, to prevent conflicts with the detection of
Maniac Mansion / Zak C64 and possibile flooding in mass-add.