diff options
author | Paul Janzen <pjanzen@cvs.openbsd.org> | 2001-03-30 04:41:35 +0000 |
---|---|---|
committer | Paul Janzen <pjanzen@cvs.openbsd.org> | 2001-03-30 04:41:35 +0000 |
commit | fbb9fa26f4c53ee82b6188e40711a3331756be89 (patch) | |
tree | acac432b30c03e7d52b2e19afc23b609c37bec10 /games/backgammon | |
parent | 33ff0d5957bafa1672055e73877ff2fe07d7cd10 (diff) |
filename length fix from ianm@cit.uws.edu.au; also, don't overflow the buffer.
Diffstat (limited to 'games/backgammon')
-rw-r--r-- | games/backgammon/common_source/save.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/games/backgammon/common_source/save.c b/games/backgammon/common_source/save.c index 17840cc74d6..7cf1dbdbe03 100644 --- a/games/backgammon/common_source/save.c +++ b/games/backgammon/common_source/save.c @@ -1,4 +1,4 @@ -/* $OpenBSD: save.c,v 1.5 1999/07/31 21:57:41 pjanzen Exp $ */ +/* $OpenBSD: save.c,v 1.6 2001/03/30 04:41:34 pjanzen Exp $ */ /* * Copyright (c) 1980, 1993 @@ -37,10 +37,11 @@ #if 0 static char sccsid[] = "@(#)save.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$OpenBSD: save.c,v 1.5 1999/07/31 21:57:41 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: save.c,v 1.6 2001/03/30 04:41:34 pjanzen Exp $"; #endif #endif /* not lint */ +#include <sys/param.h> #include <errno.h> #include "back.h" @@ -61,7 +62,7 @@ save(n) { int fdesc; char *fs; - char fname[50]; + char fname[MAXPATHLEN]; if (n) { if (tflag) { @@ -89,7 +90,10 @@ save(n) writec('\007'); continue; } - writec(*fs++); + if (fs - fname < MAXPATHLEN - 1) + writec(*fs++); + else + writec('\007'); } *fs = '\0'; if ((fdesc = open(fname, O_RDWR)) == -1 && errno == ENOENT) { |