From 95d2b48ee28edcc504e3caf95ddb6d008d54cad0 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 3 Oct 2005 10:45:00 +0000 Subject: [PATCH] (match_user, main): Use full buffer for fgets(); was off by one. --- src/lib/player/player.c | 4 ++-- src/util/files.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/player/player.c b/src/lib/player/player.c index aef6cd8c4..9f10d5c8f 100644 --- a/src/lib/player/player.c +++ b/src/lib/player/player.c @@ -393,11 +393,11 @@ match_user(char *file, struct player *p) } match = 0; while (!feof(fp) && !match) { - if (fgets(host, sizeof(host) - 1, fp) == NULL) + if (fgets(host, sizeof(host), fp) == NULL) break; if (host[0] == '#') continue; - if (fgets(user, sizeof(user) - 1, fp) == NULL) + if (fgets(user, sizeof(user), fp) == NULL) break; host[strlen(host) - 1] = '\0'; user[strlen(user) - 1] = '\0'; diff --git a/src/util/files.c b/src/util/files.c index 9b228587d..189ef1a70 100644 --- a/src/util/files.c +++ b/src/util/files.c @@ -118,7 +118,7 @@ main(int argc, char *argv[]) printf("WARNING: this blasts the existing game in %s (if any)\n", datadir); printf("continue? "); - fgets(buf, sizeof(buf) - 1, stdin); + fgets(buf, sizeof(buf), stdin); if (*buf != 'y' && *buf != 'Y') exit(1); } -- 2.43.0