diff options
author | Gilles Chehade <gilles@cvs.openbsd.org> | 2007-09-11 15:21:06 +0000 |
---|---|---|
committer | Gilles Chehade <gilles@cvs.openbsd.org> | 2007-09-11 15:21:06 +0000 |
commit | 18590f6c720ae49a5bb4d811e6827d85c513fcfe (patch) | |
tree | faa7e813da1b9d96e659b374d353a543d00380bf /games/bcd | |
parent | a737f2f8b1f877858f2553f91964fd9c3ab037fc (diff) |
use strcspn to properly overwrite '\n' in fgets returned buffer
ok pyr@, ray@, millert@, moritz@, chl@
Diffstat (limited to 'games/bcd')
-rw-r--r-- | games/bcd/bcd.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/games/bcd/bcd.c b/games/bcd/bcd.c index 063ddd940d7..f7e8cc3ec75 100644 --- a/games/bcd/bcd.c +++ b/games/bcd/bcd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bcd.c,v 1.11 2004/07/09 15:59:26 deraadt Exp $ */ +/* $OpenBSD: bcd.c,v 1.12 2007/09/11 15:21:05 gilles Exp $ */ /* $NetBSD: bcd.c,v 1.6 1995/04/24 12:22:23 cgd Exp $ */ /* @@ -43,7 +43,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)bcd.c 8.2 (Berkeley) 3/20/94"; #else -static char rcsid[] = "$OpenBSD: bcd.c,v 1.11 2004/07/09 15:59:26 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: bcd.c,v 1.12 2007/09/11 15:21:05 gilles Exp $"; #endif #endif /* not lint */ @@ -155,8 +155,7 @@ printcard(char *str) char *p; /* ruthlessly remove newlines and truncate at 48 characters. */ - if ((p = strchr(str, '\n'))) - *p = '\0'; + str[strcspn(str, "\n")] = '\0'; if (strlen(str) > COLUMNS) str[COLUMNS] = '\0'; |