bugs in file(1) on BTL SYS V (maybe others)

R.MAUS rick at ariel.UUCP
Tue Aug 20 09:18:29 AEST 1985


This line intentionally left non-blank for outdated news facilities.

(Copy of bug report reported to UNIX Support Group via "trouble" system)

BUG #1
    Index:
	.../src/cmd/file/file.c	(BTL SYS V)
    Description:
	"file(1)" fails	to match binary	data when the most significant bit
	is set for "short" types on Vaxen machines.  This is due to sign
	extension when the data	is internally converted	to a "long".
    Repeat-By:
	Create a test data file	that has a "short" value of "0177545" as
	the contents.  Use the following entry in the "/etc/magic" file	(or
	alternate).

		0	short	0177545		I bet you don't	see this!

	Run "file" over	the test data file.
    Fix:
	You can	probably modify	the following code:

		case SHORT:
			val = (long)(*(short *)	p);
			break;

	to read	(something to the effect of):

		case SHORT:
			val = (long)(*(unsigned	short *) p);
			break;

	This is	a quick	hack at	best.

BUG #2
    Index:
	.../src/cmd/file/file.c	(BTL SYS V)
    Description:
	"file(1)" does not check the "type" field of the "magic" file for a
	complete pattern match,	but rather it keys off the first few
	letters.  Therefore, the following "type" patterns are legal:

		PATTERN	TYPE	COMMENT
		sh*	short
		s*	string	After "sh*" pattern has	been eliminated.
		l*	long
    Fix:
	Use full string	comparision on the type	field.

BUG #3
    Index:
	.../src/cmd/file/file.c	(BTL SYS V)
    Description:
	No provision for "byte"	(or "char") specifier type.  It	would also
	be nice	to have	an "unsigned" type.
    Fix:
	Some of	the scaffolding	for the	code exists, but no check is made
	for the	type against the "magic" file.	The rest is left as an
	exercise for the reader.
--

				Richard L. Maus, Jr. (Rick)
				AT&T-ISL HO 1K313 201-834-4532
				...!ho???!ariel!rick



More information about the Net.bugs mailing list