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.
This commit is contained in:
John "Elwin" Edwards 2021-05-03 19:05:37 -04:00
parent 2b6d8bcb77
commit 3dfd8fd09b
13 changed files with 51 additions and 78 deletions

View file

@ -16,6 +16,7 @@
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <limits.h>
#include <errno.h>
#ifdef BSD
#include <sys/time.h>
@ -59,6 +60,7 @@ main(int argc, char *argv[], char *envp[])
*/
strncpy(home, md_gethomedir(), LINELEN);
home[LINELEN-1] = '\0';
/* Get default save file */
strcpy(file_name, home);
@ -66,8 +68,8 @@ main(int argc, char *argv[], char *envp[])
/* Get default score file */
#ifdef SCOREFILE
strncpy(score_file, SCOREFILE, LINELEN);
score_file[LINELEN-1] = '\0';
strncpy(score_file, SCOREFILE, PATH_MAX);
score_file[PATH_MAX-1] = '\0';
#else
strcpy(score_file, md_getroguedir());