summaryrefslogtreecommitdiff
path: root/games
diff options
context:
space:
mode:
Diffstat (limited to 'games')
-rw-r--r--games/rogue/save.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/games/rogue/save.c b/games/rogue/save.c
index 135e0db0998..efd531fd40b 100644
--- a/games/rogue/save.c
+++ b/games/rogue/save.c
@@ -109,9 +109,14 @@ char *sfile;
if (sfile[0] == '~') {
if (hptr = md_getenv("HOME")) {
- (void) strcpy(name_buffer, hptr);
- (void) strcat(name_buffer, sfile+1);
- sfile = name_buffer;
+ if (strlen(hptr) + strlen(sfile+1) < sizeof(name_buffer)) {
+ (void) strcpy(name_buffer, hptr);
+ (void) strcat(name_buffer, sfile+1);
+ sfile = name_buffer;
+ } else {
+ message("homedir is too long", 0);
+ return;
+ }
}
}
if ( ((fp = fopen(sfile, "w")) == NULL) ||