Christos Zoulas [Tue, 13 May 2014 16:44:24 +0000 (16:44 +0000)]
Roman I Khimov:
access() can't handle NULL as first argument and we can end up
calling it this way if inname is NULL in file_or_fd() and fd is a
pipe. Issue spotted by clang static analysis.
Christos Zoulas [Tue, 13 May 2014 16:41:06 +0000 (16:41 +0000)]
Roman I Khimov:
If cdf_count_chain() is called with sid < 0, then we end up returning
zero length, which in turn leads to calloc() calls for 0 bytes in
cdf_read_long_sector_chain(), cdf_read_short_sector_chain() and
cdf_read_ssat(). Depending on calloc() implementation we can end
up returning -1 or 0 from those. As negative sid is probably wrong
case anyway, it might be better to always return -1.
Issue found by clang static analysis.
Christos Zoulas [Tue, 13 May 2014 16:38:23 +0000 (16:38 +0000)]
Roman I Khimov:
If file_reset() fails for some reason, we pass uninitialized sb to
close_and_restore() which uses it for utimes().
Issue spotted by clang static analysis.
Christos Zoulas [Mon, 5 May 2014 16:11:21 +0000 (16:11 +0000)]
Apply patches from file-CVE-2012-1571.patch
From Francisco Alonso Espejo:
file < 5.18/git version can be made to crash when checking some
corrupt CDF files (Using an invalid cdf_read_short_sector size)
The problem I found here, is that in most situations (if
h_short_sec_size_p2 > 8) because the blocksize is 512 and normal
values are 06 which means reading 64 bytes.As long as the check
for the block size copy is not checked properly (there's an assert
that makes wrong/invalid assumptions)
Christos Zoulas [Fri, 2 May 2014 00:26:49 +0000 (00:26 +0000)]
From Christoph Biedl:
Debian bug #745546 et al: At the moment, the magic for "Macromedia
Flash data" and "Macromedia Flash Video" is just three printable
characters, no wonder this results in mis-detection of text files.
"Flash Video" is easy to fix, according to Wikipedia the forth
octet must have value 1.
"Flash data" is more work. The length information at offset 4 must be
non-zero, and the version number at offset 3 must be sound. According
to the pdf document, the latest version is 19, I found a few examples
in the lower twenties, so 32 should be a sane limit for the time
being. There are however quite a few files with version 255, and since
the virus scanners created an alert for all of them, they are now
reported as "suspicious".
Christos Zoulas [Sun, 30 Mar 2014 21:41:45 +0000 (21:41 +0000)]
raise the strength of the targa magic, instead of dropping the cursor magic
so that they does not get recognized as lotus 123 files. From Christoph Biedl
Christos Zoulas [Fri, 14 Mar 2014 19:02:37 +0000 (19:02 +0000)]
PR/319: Remove superfluous call to file_ascmagic_with_encoding. file_encoding
should have set looks_text correctly before, and file_ascmagic already calls
file_ascmagic_with_encoding if it needs to.
Christos Zoulas [Sat, 8 Mar 2014 17:26:48 +0000 (17:26 +0000)]
FIx windows icons and cursors (Christoph Biedl)
the detection of MS-Windows icon files was buggy and incomplete. Since
non-animated cursors have a very similar format, they are added here,
too.
Some details: Using only the very first four octets for determination
has always some risk of false detection. So additionally look at
offset 9 which should always be zero, but according to Wikipedia might
also be 0xff.
In "number of colors" at offset 8, the zero value previously was used
to describe "256 colors", according to Wikipedia this isn't true, so
it was dropped.
On a side node: This introduces another usage of name/use. I'm afraid
we might sooner or later end up in name clashes on these identifiers.
Feel free to extend them like prefixing with the file name "msdos-".
Also, I was a bit surprised no "message" in "use" is printed, I wanted
to do
>>4 use ico-dir MS Windows icon resource
but that message gets lost. Hence the hackery
>>0 byte x MS Windows icon resource
>>4 use ico-dir
So a feature request: Print any message in "use".
This patch by the way fixes Debian#562250. It just got a little
bigger.
Christos Zoulas [Thu, 6 Mar 2014 16:37:16 +0000 (16:37 +0000)]
Fixes from Christoph Biedl:
Inspired by Debian#588953 that rightly complained about poor
recognition of avr32 ELF files: There have been changes since the
original bug submission, file(1) now detects them as
but this was an impetus to update the list of "machines" (ELF speak),
or "architectures".
The list was taken from binutils-2.24:include/elf/common.h with some
extra research. Numbers marked "reserved" were excluded.
Additional changes:
* sorted strictly by machine number.
* some missing trailing comma added.
* slight change in Motorola names for clarity.
* fix obviously wrong endianess in 138 = LatticeMico32.
* marked all inofficial numbers as such (unless already "obsolete").
* description trimmed to keep strings short. Perhaps even any
trailing "familiy" should be dropped for the same reason.
For your information, the two attached files were used as starting
point:
elf-archs-file.magic: The relevant lines in magic/Magic/elf
elf-archs-binutils.magic: The relevant lines in include/elf/common.h,
sorted, converted into magic
As you can see, several names still differ, and it's not always easy
to judge which is better. The most prominent difference is machine
number 9, "IBM System/370" vs. "Amdahl". There's a reason for both,
and I decided to keep the name currently used by file(1).
Fun fact: file(1) knows more machine numbers than binutils.