summaryrefslogtreecommitdiffstats
path: root/usr.bin/sdiff
diff options
context:
space:
mode:
authorbapt <bapt@FreeBSD.org>2016-04-30 14:48:30 +0000
committerbapt <bapt@FreeBSD.org>2016-04-30 14:48:30 +0000
commit47bc90320f03d4b4e990a3ddd8411e4e330d7d1e (patch)
tree7354719c7a644b1a64efc896d1db4e1edc58d499 /usr.bin/sdiff
parent24be79982e1c0cf2bdca5966cc6bb8f33b3cbb37 (diff)
downloadFreeBSD-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.c4
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);
OpenPOWER on IntegriCloud