diff options
author | Wolfram Schneider <wosch@FreeBSD.org> | 2022-01-30 13:08:42 +0000 |
---|---|---|
committer | Wolfram Schneider <wosch@FreeBSD.org> | 2022-01-30 13:08:42 +0000 |
commit | 8e7c0a6d32c45ebad5bda14be0b8f03a43361743 (patch) | |
tree | 3464f74426dd62cac4b4e512b4d3e157c0c05971 /usr.bin | |
parent | 72a0982cd529c7cdeee7fd4eb7b1fd8bfdd545cb (diff) | |
download | src-8e7c0a6d32c45ebad5bda14be0b8f03a43361743.tar.gz src-8e7c0a6d32c45ebad5bda14be0b8f03a43361743.zip |
fix fgets error handling (from last commit)
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/locate/code/locate.code.c | 6 |
1 files 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"); |