diff options
author | Ray Lai <ray@cvs.openbsd.org> | 2009-06-01 13:05:00 +0000 |
---|---|---|
committer | Ray Lai <ray@cvs.openbsd.org> | 2009-06-01 13:05:00 +0000 |
commit | fc7678b4f83d3e3982caba2cb908da6fc28b788f (patch) | |
tree | 2c8e865a79fc0d167e94a5401554fff334b2df27 | |
parent | d00ac1f33f08222b9e02144aa9d038d7cfd422c0 (diff) |
Don't assume there will be a newline after calling fgets.
OK millert
-rw-r--r-- | games/atc/main.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/games/atc/main.c b/games/atc/main.c index 335ff78240b..456ec1f0750 100644 --- a/games/atc/main.c +++ b/games/atc/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.19 2007/09/14 14:29:20 chl Exp $ */ +/* $OpenBSD: main.c,v 1.20 2009/06/01 13:04:59 ray Exp $ */ /* $NetBSD: main.c,v 1.4 1995/04/27 21:22:25 mycroft Exp $ */ /*- @@ -52,7 +52,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$OpenBSD: main.c,v 1.19 2007/09/14 14:29:20 chl Exp $"; +static char rcsid[] = "$OpenBSD: main.c,v 1.20 2009/06/01 13:04:59 ray Exp $"; #endif #endif /* not lint */ @@ -338,7 +338,8 @@ list_games(void) } puts("available games:"); while (fgets(line, sizeof(line), fp) != NULL) { - printf(" %s", line); + line[strcspn(line, "\n")] = '\0'; + printf(" %s\n", line); num_games++; } fclose(fp); |