Mercurial > hg > early-roguelike
comparison arogue7/main.c @ 310:827441d05b3e
Advanced Rogue family: fix some potential buffer overflows.
Some code for determining the score file location assumed that PATH_MAX
would be less than 1024, which cannot be guaranteed.
Advanced Rogue 5 and 7, and XRogue, have had the buffers for the file
name enlarged. UltraRogue never called the functions, so the code has
been deleted instead.
| author | John "Elwin" Edwards |
|---|---|
| date | Mon, 03 May 2021 19:05:37 -0400 |
| parents | d3968e9cb98d |
| children |
comparison
equal
deleted
inserted
replaced
| 309:11aeff9acc07 | 310:827441d05b3e |
|---|---|
| 14 | 14 |
| 15 #include "curses.h" | 15 #include "curses.h" |
| 16 #include <stdlib.h> | 16 #include <stdlib.h> |
| 17 #include <string.h> | 17 #include <string.h> |
| 18 #include <signal.h> | 18 #include <signal.h> |
| 19 #include <limits.h> | |
| 19 #include <errno.h> | 20 #include <errno.h> |
| 20 #ifdef BSD | 21 #ifdef BSD |
| 21 #include <sys/time.h> | 22 #include <sys/time.h> |
| 22 #else | 23 #else |
| 23 #include <time.h> | 24 #include <time.h> |
| 57 /* | 58 /* |
| 58 * get home and options from environment | 59 * get home and options from environment |
| 59 */ | 60 */ |
| 60 | 61 |
| 61 strncpy(home, md_gethomedir(), LINELEN); | 62 strncpy(home, md_gethomedir(), LINELEN); |
| 63 home[LINELEN-1] = '\0'; | |
| 62 | 64 |
| 63 /* Get default save file */ | 65 /* Get default save file */ |
| 64 strcpy(file_name, home); | 66 strcpy(file_name, home); |
| 65 strcat(file_name, "arogue77.sav"); | 67 strcat(file_name, "arogue77.sav"); |
| 66 | 68 |
| 67 /* Get default score file */ | 69 /* Get default score file */ |
| 68 #ifdef SCOREFILE | 70 #ifdef SCOREFILE |
| 69 strncpy(score_file, SCOREFILE, LINELEN); | 71 strncpy(score_file, SCOREFILE, PATH_MAX); |
| 70 score_file[LINELEN-1] = '\0'; | 72 score_file[PATH_MAX-1] = '\0'; |
| 71 #else | 73 #else |
| 72 strcpy(score_file, md_getroguedir()); | 74 strcpy(score_file, md_getroguedir()); |
| 73 | 75 |
| 74 if (*score_file) | 76 if (*score_file) |
| 75 strcat(score_file,"/"); | 77 strcat(score_file,"/"); |
