magic number or versioning, relied on random(3) never changing to a
different implementation, and were also saving pointers to disk and
reading them back again. It *looks* as if the pointers thus loaded
were reset before being used, but it's not particularly clear as the
main loop of this thing is goto-based FORTRAN translated lightly to C.
I've changed the logic to null these pointers instead of saving and
loading them, and things seem to still work.
The new save files have a header, support versioning, write only sized
types in network byte order, and for the toy encryption to discourage
cheating do something self-contained instead of using random(3) as a
stream cipher.
Because between the original import from 4.4 until earlier today
trying to save would result in SIGSEGV on most platforms, it's
unlikely anyone has a save file, but just in case (since the pointer
issue appears to be nonlethal) I've kept compat code for old save
files.
chars by default (i.e., almost all machines). Makes it possible to save
the game. This has been broken since 4.4 and probably ever since the
FORTRAN -> C translation.
Crash reported by Petri Laakso in private mail.
so that we don't end up storing garbage accidentally and the next pointer is
initialized. If there is an inconsistency in the file abort instead
of dereferencing NULL.
* Don't bother prefixing commands with a line of ${_MKCMD}\
and instead rely upon "make -s". This is less intrusive on
all the Makefiles than the former. Idea from David Laight.
* Rename the variables use to print messages. The scheme now is:
_MKMSG_FOO Run _MKMSG 'foo'
_MKTARGET_FOO Run _MKMSG_FOO ${.TARGET}
From discussion with Alistair Crooks.
objects in its header file, and to add corresponding definitions to
init.c accordingly. (See the C standard - relying on linker commons
where there are multiple uninitialised declarations of an object in
the program traditionally works on Unix, but is not standard C.)
The patch also removes a bit-rotten code fragment under #ifdef
OLDSTUFF.
Patch submitted in PR 8105 by Joseph Myers <jsm28@cam.ac.uk>
adventure(6). The handling of this variable is somewhat confusing,
since it is used for two different purposes (controlling the time
required before a saved game can be restored, and controlling various
aspects of dwarf behaviour); in fact, it is also declared twice in
hdr.h. Except possibly when saving a game fails, these uses can never
interfere; when used for controlling dwarf behaviour, we always have
saved == -1. This can be better understood with reference to the
original PDP-10 FORTRAN source (URL in patch, since hdr.h references
the comments of the FORTRAN as still relevant to this version) of
which the C version is a direct translation: the wrong value for
`saved' meant that someone was cheating and had bypassed normal
initialisation. Saving was done by halting and telling the user to
save their core image, so the question of carrying on after saving
failed to open the output file did not arise.
This patch separates the uses of `saved' into uses of two separate
variables.
Closes PR 8005 by Joseph Myers <jsm28@cam.ac.uk>
games/adventure/setup.c fails to check for errors when writing its
output. This means that, if the disk fills up at this point during a
build, it would nevertheless fail to return an error status.
use of const I missed in bin/6041; avoiding a signed/unsigned warning;
marking an unused parameter as such; revoking setgid privileges
(including the saved gid) rather than setuid ones; includes and
function prototypes in setup.c; the string passed to err() should not
end with a `.'. Together with the patch sent concerning adventure's
EOF handling, this synchronises adventure(6) in NetBSD with the Linux
port of the NetBSD games.
Via PR 6557 by Joseph Myers <jsm28@cam.ac.uk>