Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 30 Jan 2022 13:09:22 GMT
From:      Wolfram Schneider <wosch@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 8e7c0a6d32c4 - main - fix fgets error handling (from last commit)
Message-ID:  <202201301309.20UD9MPX015876@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by wosch:

URL: https://cgit.FreeBSD.org/src/commit/?id=8e7c0a6d32c45ebad5bda14be0b8f03a43361743

commit 8e7c0a6d32c45ebad5bda14be0b8f03a43361743
Author:     Wolfram Schneider <wosch@FreeBSD.org>
AuthorDate: 2022-01-30 13:08:42 +0000
Commit:     Wolfram Schneider <wosch@FreeBSD.org>
CommitDate: 2022-01-30 13:08:42 +0000

    fix fgets error handling (from last commit)
---
 usr.bin/locate/code/locate.code.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/usr.bin/locate/code/locate.code.c b/usr.bin/locate/code/locate.code.c
index 23fa043b12af..9da78d55e622 100644
--- a/usr.bin/locate/code/locate.code.c
+++ b/usr.bin/locate/code/locate.code.c
@@ -144,8 +144,10 @@ main(int argc, char *argv[])
 		err(1, "%s", argv[0]);
 
 	/* First copy bigram array to stdout. */
-	if (fgets(bigrams, BGBUFSIZE + 1, fp) == NULL)
-		err(1, "get bigram array");
+	if (fgets(bigrams, BGBUFSIZE + 1, fp) == NULL) {
+		if (!feof(fp) || ferror(fp))
+			err(1, "get bigram array");
+	}
 
 	if (fwrite(bigrams, 1, BGBUFSIZE, stdout) != BGBUFSIZE)
 		err(1, "stdout");



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202201301309.20UD9MPX015876>