Home | History | Annotate | Download | only in rogue
History log of /src/games/rogue/rogue.h
RevisionDateAuthorComments
 1.25  07-Apr-2025  hgutch Fix loading save files

Both monster and weapon damage are represented as strings like "1d1", and
internally the game keeps track of them as pointers to static strings
in memory. When saving, the game saves these pointers and when loading
them the pointers end up being identical to before - which now points to
undefined memory.

So when loading a save game, reset the damage strings based on the type
of monster or weapon.

Pointed out and fix suggested by Anthony C Howe <achowe@snert.com>
(committed with a small modification of said patch).
 1.24  11-Aug-2013  dholland branches: 1.24.36;
WARNS=5
 1.23  11-Aug-2013  dholland typo in comment
 1.22  26-Aug-2011  dholland branches: 1.22.2; 1.22.8;
Use __dead and __printflike instead of __attribute__.
 1.21  23-May-2011  joerg Kill some pointer indirections. Don't use variables as format strings.
 1.20  12-Aug-2009  dholland sprinkle static
 1.19  14-Jan-2008  dholland ANSIfy. Remove unnecessary casts. Clean up for -Wsign-compare. Make more
things file-static. Other minor tidyups, and fix a couple minor bugs found
along the way.
 1.18  27-Dec-2007  dholland Comprehensive (or at least extensive) string handling cleanup for rogue.

This patch dates (mostly) back to 2002; the critical parts of it were
handled back then by security-officer. As far as I know, there's
nothing exploitable fixed herein.

A slightly earlier version of this patch was reviewed by Christian Biere
when I filed it as PR 34750.
 1.17  15-Feb-2005  jsm branches: 1.17.16;
Avoid arrays of incomplete types (required to build with GCC 4).

Reviewed by <hubertf>.
 1.16  27-Jan-2004  jsm Remove uses of __P.
 1.15  01-Jan-2004  jsm Don't use -fwritable-strings. Add one more const.
 1.14  07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22269, verified by myself.
 1.13  01-Oct-2002  mrg - use correctly bounded strings when reloading a saved game. in particular,
do not let the save game file "string length" exceed the amount of space
supplied. as noted by <stanojr@iserver.sk> on bugtraq.
- minor KNF.

tested by simonb.
 1.12  05-Feb-2001  christos branches: 1.12.2;
remove duplicate decls
 1.11  13-Sep-1999  jsm branches: 1.11.8;
Remove rogue's old and bit-rotten cut-down version of curses.
 1.10  12-Sep-1999  jsm Security improvements for games (largely from or inspired by OpenBSD).

Games which run setgid from dm, but don't need to, should drop their
privileges at startup.

Games which have a scorefile should open it at startup, then drop all
privileges leaving just the open writable file descriptor. If the
game can invoke subprocesses, this should be made close-on-exec.

Games with scorefiles should make sure they do not get a file
descriptor < 3. (Otherwise, they could get confused and corrupt the
scorefile when using stdin, stdout or stderr.)

Some old setuid revokes from the days of setuid games change into gid
revokes.
 1.9  08-Sep-1999  jsm Add `__noreturn__' and `__unused__' attributes where appropriate to
the games.

This merges in all such remaining changes from the Linux port of the
NetBSD games, except in hunt (where substantial changes from OpenBSD
need to be looked at).

Most noreturn attributes were previously added in bin/6144, with some
others that were missed then in bin/8082. Previous `unused'
attributes were covered in bin/6557, bin/8058 and other PRs (all these
PRs have already been handled and closed).
 1.8  10-Nov-1998  hubertf constify, per PR 6148
 1.7  13-Sep-1998  hubertf mark non-returning functions (PR#6144 by Joseph Myers <jsm28@cam.ac.uk>)
 1.6  27-Jul-1998  mycroft const poisoning.
 1.5  12-Oct-1997  lukem WARNSify (not an insignificant task...)
 1.4  24-Apr-1995  cgd Various changes to make games compile w/o warnings on the alpha:
Include appropriate includes, delete bogus function declarations,
change sizes of variables and casts.
 1.3  22-Apr-1995  cgd clean up import, NetBSD RCS Ids
 1.2  01-Aug-1993  mycroft Add RCS identifiers.
 1.1  21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2  22-Apr-1995  cgd src/games/rogue from Lite
 1.1.1.1  21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.11.8.1  02-Oct-2002  itojun games/rogue/inventory.c 1.8
games/rogue/save.c 1.8
games/rogue/message.c 1.9
games/rogue/rogue.h 1.13

Use correctly bounded strings when reloading a saved game. In particular,
do not let the save game file "string length" exceed the amount of space
supplied. As noted by <stanojr@iserver.sk> on bugtraq. Fixes SA#2002-021.

(mrg)
 1.12.2.1  01-Oct-2002  lukem Pull up revision 1.13 (requested by mrg in ticket #892):
- use correctly bounded strings when reloading a saved game. in particular,
do not let the save game file "string length" exceed the amount of space
supplied. as noted by <stanojr@iserver.sk> on bugtraq.
- minor KNF.
tested by simonb.
 1.17.16.2  23-Mar-2008  matt sync with HEAD
 1.17.16.1  09-Jan-2008  matt sync with HEAD
 1.22.8.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.22.2.1  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.24.36.1  12-Apr-2025  martin Pull up following revision(s) (requested by hgutch in ticket #1090):

games/rogue/rogue.h: revision 1.25
games/rogue/play.c: revision 1.11
games/rogue/monster.c: revision 1.18
games/rogue/save.c: revision 1.15
games/rogue/object.c: revision 1.15

Fix segfault when canceling "Quit" operation

When pressing 'Q' followed by anything other than 'y', make sure not to
end up calling __unreachable().
Pointed out by Anthony C Howe <achowe%snert.com@localhost>

Fix loading save files

Both monster and weapon damage are represented as strings like "1d1", and
internally the game keeps track of them as pointers to static strings
in memory. When saving, the game saves these pointers and when loading
them the pointers end up being identical to before - which now points to
undefined memory.

So when loading a save game, reset the damage strings based on the type
of monster or weapon.

Pointed out and fix suggested by Anthony C Howe <achowe%snert.com@localhost>
(committed with a small modification of said patch).

RSS XML Feed