Mercurial > hg > early-roguelike
annotate arogue7/mach_dep.h @ 176:db1c9a21a7c3
srogue: prevent overflowing the score file name.
If SCOREFILE is not defined, roguehome() is called to find a directory
for the score file.  It copies up to PATH_MAX-20 bytes from an
environment variable to a static buffer.  Later these are strcpy()'d to
scorefile, which is of size LINLEN.  Unfortunately LINLEN is 80 and
PATH_MAX is at least 256.  On Linux, it happens to be 4096.
I haven't yet managed to crash or exploit it, but there are surely no
beneficial consequences, so roguehome() has been modified to check the
length, and the string it returns is also checked in main().
| author | John "Elwin" Edwards | 
|---|---|
| date | Sun, 02 Aug 2015 12:14:47 -0400 | 
| parents | 44a0fce4b168 | 
| children | 4b1999ac91cf | 
| rev | line source | 
|---|---|
| 
125
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
1 /* | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
2 * mach_dep.h - machine dependicies | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
3 * | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
4 * Advanced Rogue | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
5 * Copyright (C) 1984, 1985, 1986 Michael Morgan, Ken Dalka and AT&T | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
6 * All rights reserved. | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
7 * | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
8 * Based on "Rogue: Exploring the Dungeons of Doom" | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
9 * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
10 * All rights reserved. | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
11 * | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
12 * See the file LICENSE.TXT for full copyright and licensing information. | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
13 */ | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
14 | 
| 
159
 
44a0fce4b168
arogue7, xrogue: fix configure's wizardmode and limitscore options.
 
John "Elwin" Edwards 
parents: 
156 
diff
changeset
 | 
15 /* Set these options, if not using config.h */ | 
| 
 
44a0fce4b168
arogue7, xrogue: fix configure's wizardmode and limitscore options.
 
John "Elwin" Edwards 
parents: 
156 
diff
changeset
 | 
16 #ifndef HAVE_CONFIG_H | 
| 
125
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
17 /* | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
18 * define that the wizard commands exist | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
19 */ | 
| 
159
 
44a0fce4b168
arogue7, xrogue: fix configure's wizardmode and limitscore options.
 
John "Elwin" Edwards 
parents: 
156 
diff
changeset
 | 
20 #undef WIZARD /* 0 */ | 
| 
125
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
21 | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
22 /* | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
23 * define if you want to limit scores to one per class per userid | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
24 */ | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
25 #undef LIMITSCORE /* 1 */ | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
26 | 
| 
159
 
44a0fce4b168
arogue7, xrogue: fix configure's wizardmode and limitscore options.
 
John "Elwin" Edwards 
parents: 
156 
diff
changeset
 | 
27 #endif | 
| 
 
44a0fce4b168
arogue7, xrogue: fix configure's wizardmode and limitscore options.
 
John "Elwin" Edwards 
parents: 
156 
diff
changeset
 | 
28 | 
| 
125
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
29 /* | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
30 * define that rogue should "nice()" itself | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
31 */ | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
32 #undef NICE /* 1 */ | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
33 | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
34 #ifdef NICE | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
35 #define FUDGE_TIME 70 /* fudge factor allowed in time for saved game*/ | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
36 #else | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
37 #define FUDGE_TIME 50 /* fudge factor allowed in time for saved game*/ | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
38 #endif | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
39 | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
40 #undef DUMP /* 1 */ /* dump core rather than catch the signal */ | 
