bin/170415: file(1) fails to detect troff (and other file types)

Stephen McKay mckay at
Mon Aug 6 12:30:02 UTC 2012

>Number:         170415
>Category:       bin
>Synopsis:       file(1) fails to detect troff (and other file types)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Aug 06 12:30:01 UTC 2012
>Originator:     Stephen McKay
>Release:        9.1-beta1
A bug was introduced into file(1) 5.11 when it was imported into the FreeBSD base.  Detection of troff files (and others) has been broken.  This is because "search" and "regex" patterns are no longer correctly processed by "mkmagic", the program that compiles /usr/share/misc/magic.mgc from the individual pattern files.
$ echo '.tr' > foo
$ file foo
foo: ASCII text

Expected behaviour is:

$ file foo
foo: troff or preprocessor input, ASCII text

Apply the (hopefully) attached patch against 10-current.

Patch attached with submission follows:

Index: contrib/file/apprentice.c
RCS file: /cvs/src/contrib/file/apprentice.c,v
retrieving revision 1.7
diff -u -r1.7 apprentice.c
--- contrib/file/apprentice.c	19 Apr 2012 03:20:13 -0000	1.7
+++ contrib/file/apprentice.c	6 Aug 2012 12:01:01 -0000
@@ -648,7 +648,6 @@
 	case FILE_REGEX:
 		/* Check for override */
 		if (mstart->str_flags & STRING_BINTEST)
 			mstart->flag |= BINTEST;
@@ -664,7 +663,6 @@
 			mstart->flag |= BINTEST;
 			mstart->flag |= TEXTTEST;
 		/* can't deduce anything; we shouldn't see this at the
Index: lib/libmagic/Makefile
RCS file: /cvs/src/lib/libmagic/Makefile,v
retrieving revision 1.18
diff -u -r1.18 Makefile
--- lib/libmagic/Makefile	19 May 2012 02:30:10 -0000	1.18
+++ lib/libmagic/Makefile	6 Aug 2012 12:02:03 -0000
@@ -39,7 +39,7 @@
 CLEANFILES+=	mkmagic
 build-tools: mkmagic
-mkmagic: apprentice.c funcs.c getline.c magic.c print.c
+mkmagic: apprentice.c encoding.c funcs.c getline.c magic.c print.c
 	    -o ${.TARGET} ${.ALLSRC}


More information about the freebsd-bugs mailing list