diff options
author | bapt <bapt@FreeBSD.org> | 2016-04-30 14:48:30 +0000 |
---|---|---|
committer | bapt <bapt@FreeBSD.org> | 2016-04-30 14:48:30 +0000 |
commit | 47bc90320f03d4b4e990a3ddd8411e4e330d7d1e (patch) | |
tree | 7354719c7a644b1a64efc896d1db4e1edc58d499 /usr.bin/sdiff | |
parent | 24be79982e1c0cf2bdca5966cc6bb8f33b3cbb37 (diff) | |
download | FreeBSD-src-47bc90320f03d4b4e990a3ddd8411e4e330d7d1e.zip FreeBSD-src-47bc90320f03d4b4e990a3ddd8411e4e330d7d1e.tar.gz |
When checking for binary file, check if ch is not EOF only ch actually got
a value assigned
Reported by: pfg
Diffstat (limited to 'usr.bin/sdiff')
-rw-r--r-- | usr.bin/sdiff/sdiff.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/usr.bin/sdiff/sdiff.c b/usr.bin/sdiff/sdiff.c index 0c822aa..3a97e10 100644 --- a/usr.bin/sdiff/sdiff.c +++ b/usr.bin/sdiff/sdiff.c @@ -514,12 +514,14 @@ istextfile(FILE *f) if (f == NULL) return (1); rewind(f); - for (i = 0; i <= MAX_CHECK || ch != EOF; i++) { + for (i = 0; i <= MAX_CHECK; i++) { ch = fgetc(f); if (ch == '\0') { rewind(f); return (0); } + if (ch == EOF) + break; } rewind(f); return (1); |