diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2014-05-09 02:47:26 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2014-05-09 02:47:26 +0000 |
commit | e75c6e7b50cc25bdbccb56f78295898e7117c411 (patch) | |
tree | 86629f65693cc891654eacc57567fd3decda9982 | |
parent | 471f70d79373108b1dd075df9be22ce6d1e6037c (diff) |
After entering an invalid three-letter card name, one letter card names
stopped working because the third letter remained in the buffer,
incard() skipped the NUL and used the old garbage.
Fix this bug reported by pjanzen@, but in a simpler way than he
suggested, by just clearing any trailing garbage from the buffer.
ok pjanzen@
-rw-r--r-- | games/cribbage/io.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/games/cribbage/io.c b/games/cribbage/io.c index 551c5c99386..3696d1878a0 100644 --- a/games/cribbage/io.c +++ b/games/cribbage/io.c @@ -1,4 +1,4 @@ -/* $OpenBSD: io.c,v 1.15 2014/05/09 00:03:41 schwarze Exp $ */ +/* $OpenBSD: io.c,v 1.16 2014/05/09 02:47:25 schwarze Exp $ */ /* $NetBSD: io.c,v 1.9 1997/07/09 06:25:47 phil Exp $ */ /*- @@ -552,7 +552,8 @@ get_line(void) Mpos++; } } - linebuf[pos] = '\0'; + while (pos < sizeof(linebuf)) + linebuf[pos++] = '\0'; stdscr = oscr; return (linebuf); } |