diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1996-10-28 00:12:45 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1996-10-28 00:12:45 +0000 |
commit | f3fe9339037d34221a416e8fcb28676b1a4929cc (patch) | |
tree | 58e668eab445669292b7f789d22d92cc061a0c56 /games | |
parent | 7c960f3f657eb9356172290dbf1f678dd3a1c6d1 (diff) |
Safe $HOME handling.
Diffstat (limited to 'games')
-rw-r--r-- | games/rogue/save.c | 11 |
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) || |