rick@ariel.UUCP (R.MAUS) (08/20/85)
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
greg@ncr-sd.UUCP (Greg Noel) (08/23/85)
In article <1005@ariel.UUCP> rick@ariel.UUCP (R.MAUS) writes: >BUG #1 > Fix: > case SHORT: > val = (long)(*(short *) p); > break; > > to read (something to the effect of): > > case SHORT: > val = (long)(*(unsigned short *) p); > break; > There is a similar cast a few lines below the one quoted that also must be fixed. Change the (long)(*(char *) p) into (long)(*(unsigned char *) p). Then the problem identified in bug #3 has a chance of working..... -- -- Greg Noel, NCR Rancho Bernardo Greg@ncr-sd.UUCP or Greg@nosc.ARPA