summaryrefslogtreecommitdiff
path: root/games
diff options
context:
space:
mode:
Diffstat (limited to 'games')
-rw-r--r--games/battlestar/externs.h1
-rw-r--r--games/battlestar/save.c18
2 files changed, 15 insertions, 4 deletions
diff --git a/games/battlestar/externs.h b/games/battlestar/externs.h
index ab7f020334d..2a0ef58f3d0 100644
--- a/games/battlestar/externs.h
+++ b/games/battlestar/externs.h
@@ -35,6 +35,7 @@
* @(#)externs.h 8.1 (Berkeley) 5/31/93
*/
+#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
diff --git a/games/battlestar/save.c b/games/battlestar/save.c
index 85c85951b68..b218d3c01e8 100644
--- a/games/battlestar/save.c
+++ b/games/battlestar/save.c
@@ -53,8 +53,13 @@ restore()
register FILE *fp;
home = getenv("HOME");
- strcpy(home1, home);
- strcat(home1, "/Bstar");
+ if (strlen(home) + 6 < sizeof(home1)) {
+ strcpy(home1, home);
+ strcat(home1, "/Bstar");
+ } else {
+ fprintf(stderr, "%s/Bstar: %s\n", home, strerror(ENAMETOOLONG));
+ return;
+ }
if ((fp = fopen(home1, "r")) == 0) {
perror(home1);
return;
@@ -106,8 +111,13 @@ save()
FILE *fp;
home = getenv("HOME");
- strcpy(home1, home);
- strcat(home1, "/Bstar");
+ if (strlen(home) + 6 < sizeof(home1)) {
+ strcpy(home1, home);
+ strcat(home1, "/Bstar");
+ } else {
+ fprintf(stderr, "%s/Bstar: %s\n", home, strerror(ENAMETOOLONG));
+ return;
+ }
if ((fp = fopen(home1, "w")) == 0) {
perror(home1);
return;