13 Mar
2014
13 Mar
'14
15:58
Hello community, here is the log from the commit of package file.2621 for openSUSE:12.3:Update checked in at 2014-03-13 16:58:36 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:12.3:Update/file.2621 (Old) and /work/SRC/openSUSE:12.3:Update/.file.2621.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "file.2621" Changes: -------- New Changes file: --- /dev/null 2014-02-13 01:09:38.344032506 +0100 +++ /work/SRC/openSUSE:12.3:Update/.file.2621.new/file.changes 2014-03-13 16:58:38.000000000 +0100 @@ -0,0 +1,810 @@ +------------------------------------------------------------------- +Tue Mar 4 16:01:58 UTC 2014 - werner@suse.de + +- Add the upstream patch + 0001-PR-313-Aaron-Reffett-Check-properly-for-exceeding-th.patch + to solve bnc#866750 - file: crash when parsing some PE executables +- Modify the upstream patch + 0001-prevent-infinite-recursion.patch + to fit with former applied patch + +------------------------------------------------------------------- +Tue Mar 4 13:19:51 UTC 2014 - werner@suse.de + +- Port the upstream patch + 0001-count-indirect-recursion-as-recursion.patch + back to avoid overflow, related to bnc#864589 as file-5.11 does + not do a recursive match detection + +------------------------------------------------------------------- +Mon Nov 26 15:23:01 UTC 2012 - werner@suse.de + +- Add file-5.11-extfs-minix.dif: Change detection order of ext2/3/4 + fs and minix to avoid the for the free inode numbers 4991,5007, + 9320,9336 and multiple of 65536 the ext2/3/4 fs will be detected + as minix fs (bnc#788435) + +------------------------------------------------------------------- +Sat Oct 27 18:37:13 UTC 2012 - coolo@suse.com + +- implement shared library policy for libmagic1 + +------------------------------------------------------------------- +Tue Sep 18 10:24:58 UTC 2012 - werner@suse.de + +- Add small patch to make clear if file follows symbloc links or not + as tihs depend on the environment variable POSIXLY_CORRECT +- Remove the README file as this is for packagers and not for users + +------------------------------------------------------------------- +Sun Aug 19 19:22:01 UTC 2012 - giecrilj@stegny.2a.pl + +- add documentation (bnc#776532) + +------------------------------------------------------------------- +Tue Aug 14 04:06:35 UTC 2012 - crrodriguez@opensuse.org + +- Use the OS's byteswapping routines. + +------------------------------------------------------------------- +Tue Jun 26 07:45:16 UTC 2012 - cfarrell@suse.com + +- license update: BSD-2-Clause + SPDX format + +------------------------------------------------------------------- +Wed Mar 21 12:39:50 UTC 2012 - werner@suse.de + +- Update to file version 5.11 (bnc#753303, CVE-2012-1571) + * Fix CDF parsing issues found by CERT's fuzzing tool (Will Dormann) + +------------------------------------------------------------------- +Mon Jan 16 13:42:35 UTC 2012 - werner@suse.de + +- Update to file version 5.10 + * Add magic for /usr/bin/env Perl scripts + * Weaken generic script magic to avoid clashing with + language-specific magic. + * Remove hardwired token finding (names.h), turning it into soft + magic. Patterns are either anchored regexs or search/8192. English + language detection and PL/1 detection have been removed as they + were too fragile. -e tokens is still accepted for backwards + compatibility. + * Move 3ds patterns (which are commented out anyway) into autodesk + (they were, oddly, in c-lang). + * Tweak strength of generic hash-bang detectors to be less than + specific ones. + * Make an inconsistent description of Python scripts consistent. + * Python3 binding fixes from Kelly Anderson + * If a string type magic entry is marked as text or binary + only match text files against text entries and binary + files against binary entries. + * If the application name is not set in a cdf file, try to see + if it has a directory with the application name on it. + * Fix ELF lseek(2) madness. Inspired by PR/134 by Jan Kaluza + * Don't use variable string formats. + +------------------------------------------------------------------- +Sat Nov 5 18:37:25 UTC 2011 - crrodriguez@opensuse.org + +- libmagic: use O_CLOEXEC where needed, as there is no warranty + that calling applications will not fork() and we end up leaking + file descriptors to their child processes. + +------------------------------------------------------------------- +Sat Oct 1 05:39:05 UTC 2011 - coolo@suse.com + +- add libtool as buildrequire to make the spec file more reliable + +------------------------------------------------------------------- +Sun Sep 18 17:17:12 UTC 2011 - jengelh@medozas.de + +- Apply packaging guidelines (remove redundant/obsolete + tags/sections from specfile, etc.) + +------------------------------------------------------------------- +Tue Aug 23 14:55:19 UTC 2011 - werner@suse.de + +- Update to file version 5.08 + * Fix detection of Zip files (Mantis #128). + * Make some minor improvements to file(1). + * Rename MIME types for filesystem objects for consistency with + xdg-utils. Typically this means that application/x-foo becomes + inode/foo, but some names also change slightly, e.g. + application/x-character-device becomes inode/chardevice. + +------------------------------------------------------------------- +Mon Jul 18 12:00:20 CEST 2011 - werner@suse.de + +- Fixed regression on zip archive detection (bnc#706310) + +------------------------------------------------------------------- +Tue Jun 14 19:50:04 CEST 2011 - werner@suse.de + +- Update to file version 5.07 + * Several regressions in magic were fixed. A buffer overflow was + corrected. The program version is now recorded in only one place. + Several documentation improvements were made. + * The Python bindings were updated and fixed. Magic support for + OCF (EPUB) files and for lrzip files was added. Zip file magic + was adapted for files with unsupported special types. Many + more magic updates and fixes were made. + * Several minor bugs were fixed. +- Add magic for clicfs evne if upstream does not support it (bnc#681329) + +------------------------------------------------------------------- +Wed Nov 24 13:17:11 CET 2010 - werner@suse.de + +- Add patch for Bio-Rad image format to avoid conflicts with other + magic records like RPM and even some ACII files (bnc#654696) + +------------------------------------------------------------------- +Fri Nov 5 22:41:23 UTC 2010 - cristian.rodriguez@opensuse.org + +- libmagic: export only public interface symbols listed + in magic.h, this also avoids exporting interesting stuff + like strlcat, strlcpy... + +------------------------------------------------------------------- +Mon Jun 28 06:38:35 UTC 2010 - jengelh@medozas.de + +- use %_smp_mflags + +------------------------------------------------------------------- +Mon Apr 19 16:18:08 CEST 2010 - werner@suse.de + +- Add llvm bicode magic (bnc#597752) + +------------------------------------------------------------------- +Fri Feb 5 17:15:51 CET 2010 - werner@suse.de + +- Update to file version 5.04 + * print proper mime for crystal reports file + * print the last summary information of a cdf document, not the + first so that nested documents print the right info + * ctime/asctime can return NULL on some OS's although + they should not (Toshit Antani) + * Centralize magic path handling routines and remove the + special-casing from file.c so that the python module for + example comes up with the same magic path (Fixes ~/.magic + handling) (from Gab) + * When magic argument is a directory, read the files in + strcmp-sorted order (fixes Debian bug #488562 and our own FIXME). + * Combine overlapping epoc and psion magic files into one (epoc). + * Add some more EPOC MIME types. + * Fix 3 bugs (From Ian Darwin): + - file_showstr could move one past the end of the array + - parse_apple did not nul terminate the string in the overflow case + - parse_mime truncated the wrong string in the overflow case + * Add the necessary field handling for crystal reports files to work + * Stop "(if" identifying Lisp files, that's plain dumb! + * Add a couple of missing MP3 MIME types. + * Add full range of hash-bang tests for Python and Ruby. + * Add MIME types for Python and Ruby scripts. + * off by one in parsing hw capabilities in elf (Cheng Renquan) + +------------------------------------------------------------------- +Sat Dec 12 22:08:00 CET 2009 - jengelh@medozas.de + +- add baselibs.conf as a source + +------------------------------------------------------------------- +Tue Nov 3 19:12:13 UTC 2009 - coolo@novell.com + +- updated patches to apply with fuzz=0 + +------------------------------------------------------------------- +Tue Oct 27 17:04:51 CET 2009 - werner@suse.de ++++ 613 more lines (skipped) ++++ between /dev/null ++++ and /work/SRC/openSUSE:12.3:Update/.file.2621.new/file.changes New Changes file: --- /dev/null 2014-02-13 01:09:38.344032506 +0100 +++ /work/SRC/openSUSE:12.3:Update/.file.2621.new/python-magic.changes 2014-03-13 16:58:38.000000000 +0100 @@ -0,0 +1,26 @@ +------------------------------------------------------------------- +Tue Mar 27 07:57:55 UTC 2012 - aj@suse.de + +- ran pre_checkin.sh + +------------------------------------------------------------------- +Sun Sep 18 17:17:12 UTC 2011 - jengelh@medozas.de + +- Apply packaging guidelines (remove redundant/obsolete + tags/sections from specfile, etc.) + +------------------------------------------------------------------- +Mon Aug 29 11:17:14 UTC 2011 - coolo@novell.com + +- ran pre_checkin.sh + +------------------------------------------------------------------- +Tue Apr 15 11:58:17 CEST 2008 - werner@suse.de + +- Also change version number in python-magic.spec + +------------------------------------------------------------------- +Mon Jan 28 18:10:23 CET 2008 - rguenther@suse.de + +- Split off from file. + New: ---- 0001-PR-313-Aaron-Reffett-Check-properly-for-exceeding-th.patch 0001-prevent-infinite-recursion.patch baselibs.conf file-4.03-tex.dif file-4.18-printf.dif file-4.20-ssd.dif file-4.20-xen.dif file-4.21-scribus.dif file-4.21-xcursor.dif file-4.24-autoconf.dif file-4.24-cromfs.dif file-4.24-mips.dif file-4.24-solv.dif file-4.24-warn.dif file-5.02-javacheck.dif file-5.07-biorad.dif file-5.07-clicfs.dif file-5.07-elf.dif file-5.07-iso9660.dif file-5.07-llvm.dif file-5.07-misc.dif file-5.07-option.dif file-5.07-zip.dif file-5.07-zip2.0.dif file-5.10-visibility.patch file-5.10.dif file-5.11-extfs-minix.dif file-5.11-nitpick.dif file-5.11.tar.gz file-endian.patch file-ocloexec.patch file.changes file.spec pre_checkin.sh python-magic.changes python-magic.spec ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ file.spec ++++++ # # spec file for package file # # Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed # upon. The license for this file, and modifications and additions to the # file, is the same license as for the pristine package itself (unless the # license for the pristine package is not an Open Source License, in which # case the license is the MIT License). An "Open Source License" is a # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. # Please submit bugfixes or comments via http://bugs.opensuse.org/ # Name: file BuildRequires: findutils BuildRequires: libtool BuildRequires: zlib-devel Url: http://www.darwinsys.com/file/ # bug437293 %ifarch ppc64 Obsoletes: file-64bit %endif # # Set Version also in python-magic.spec Version: 5.11 Release: 0 Summary: A Tool to Determine File Types License: BSD-2-Clause Group: Productivity/File utilities Source: ftp://ftp.astron.com/pub/file/file-%{version}.tar.gz Source2: baselibs.conf Patch: file-5.10.dif Patch1: file-5.07-misc.dif Patch4: file-4.24-autoconf.dif Patch5: file-4.03-tex.dif Patch7: file-4.20-ssd.dif Patch8: file-4.20-xen.dif Patch9: file-5.07-elf.dif Patch10: file-4.18-printf.dif Patch11: file-5.07-zip.dif Patch12: file-5.07-option.dif Patch13: file-4.21-scribus.dif Patch15: file-4.21-xcursor.dif Patch20: file-4.24-mips.dif Patch22: file-4.24-cromfs.dif Patch24: file-4.24-warn.dif Patch25: file-5.02-javacheck.dif Patch26: file-4.24-solv.dif Patch27: file-5.07-zip2.0.dif Patch28: file-5.07-iso9660.dif Patch29: file-5.07-llvm.dif Patch30: file-5.10-visibility.patch Patch31: file-5.07-biorad.dif Patch32: file-5.07-clicfs.dif Patch33: file-ocloexec.patch Patch34: file-endian.patch Patch35: file-5.11-nitpick.dif # PATCH-FEATURE-SLE file-5.11-extfs-minix.dif [bnc#788435] Patch36: file-5.11-extfs-minix.dif # PATCH-FIX-USTREAM bnc#866750 - file: crash when parsing some PE executables Patch99: 0001-PR-313-Aaron-Reffett-Check-properly-for-exceeding-th.patch # PATCH-FIX-USTREAM bnc#864589 - CVE-2014-1943: file: infinite recursion Patch100: 0001-prevent-infinite-recursion.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build %global _sysconfdir /etc %global _miscdir %{_datadir}/misc %description With the file command, you can obtain information on the file type of a specified file. File type recognition is controlled by the file /etc/magic, which contains the classification criteria. This command is used by apsfilter to permit automatic printing of different file types. %package -n libmagic-data Summary: The magic files for libmagic to use Group: Development/Libraries/Other %description -n libmagic-data This package contains the basic magic files that libmagic reads and uses to estimate a file's type. %package -n libmagic1 Summary: Library with file's functionality Group: Development/Libraries/Other Requires: libmagic-data = %{version} %description -n libmagic1 This library reads magic files and detects file types. Used by file command %package -n file-devel Summary: Include Files and Libraries mandatory for Development Group: Development/Libraries/Other Provides: file:/usr/include/magic.h Requires: glibc-devel Requires: libmagic1 = %{version} %description -n file-devel This package contains all necessary include files and libraries needed to develop applications that require the magic "file" interface. %prep %setup -q -n file-%{version} %patch99 -p0 %patch100 -p0 %patch1 -p0 -b .misc %patch4 -p0 -b .conf %patch5 -p0 -b .tex %patch7 -p0 -b .ssd %patch8 -p0 -b .xen %patch9 -p0 -b .elf %patch10 -p0 -b .prtf %patch11 -p0 -b .zip %patch12 -p0 -b .opt %patch13 -p0 -b .scri %patch15 -p0 -b .xcur %ifarch mips %patch20 -p0 -b .mips %endif %patch22 -p0 -b .cromfs %patch24 -p0 -b .warn %patch25 -p0 -b .javacheck %patch26 -p0 -b .solv %patch27 -p0 -b .zip2.0 %patch28 -p0 -b .iso9600 %patch29 -p0 -b .llvm %patch30 -p0 -b .vis %patch31 -p0 -b .biorad %patch32 -p0 -b .clicfs %patch33 -p0 -b .clexe %patch34 -p0 -b .endian %patch35 -p0 -b .nitpick %patch36 -p0 -b .extnotminix %patch -b .0 %build export LANG=POSIX export LC_ALL=POSIX rm -f Magdir/*,v Magdir/*~ rm -f ltcf-c.sh ltconfig ltmain.sh autoreconf -fiv CFLAGS="$RPM_OPT_FLAGS -DHOWMANY=69632" %configure --disable-silent-rules --datadir=%{_miscdir} --disable-static --with-pic --enable-fsect-man5 %{__make} %{?_smp_mflags} pkgdatadir='$(datadir)' %if 0%{?build_python_bindings:1} pushd python python setup.py build popd %endif %install export LANG=POSIX export LC_ALL=POSIX mkdir %{buildroot}/etc make DESTDIR=%{buildroot} install pkgdatadir='$(datadir)' rm -vf %{buildroot}%{_sysconfdir}/magic echo '# Localstuff: file(1) magic(5) for locally observed files' > %{buildroot}%{_sysconfdir}/magic echo '# global magic file is %{_miscdir}/magic(.mgc)' >> %{buildroot}%{_sysconfdir}/magic %{nil install -s dcore %{buildroot}%{_bindir}} # Check out that the binary does not bail out: LD_LIBRARY_PATH=%{buildroot}%{_libdir} export LD_LIBRARY_PATH find %{buildroot}%{_bindir}/file %{_bindir}/ /%{_lib}/ %{_libdir}/ | \ xargs %{buildroot}%{_bindir}/file -m %{buildroot}%{_miscdir}/magic unset LD_LIBRARY_PATH %{__rm} -f %{buildroot}%{_libdir}/*.la %post -n libmagic1 -p /sbin/ldconfig %postun -n libmagic1 -p /sbin/ldconfig %files -n libmagic1 %defattr (644,root,root,755) %{_libdir}/lib*.so.* %files -n libmagic-data %defattr (644,root,root,755) %config(noreplace) %{_sysconfdir}/magic %{_miscdir}/magic %{_miscdir}/magic.mgc %doc %{_mandir}/man5/magic.5.gz %files %defattr (644,root,root,755) %{nil %{_bindir}/dcore} %attr(755,root,root) %{_bindir}/file %doc %{_mandir}/man1/file.1.gz %doc COPYING AUTHORS NEWS ChangeLog %files -n file-devel %defattr (644,root,root,755) %{_libdir}/lib*.so %{_includedir}/magic.h %doc %{_mandir}/man3/libmagic.3.gz %doc README COPYING AUTHORS NEWS ChangeLog %changelog ++++++ python-magic.spec ++++++ # # spec file for package python-magic # # Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed # upon. The license for this file, and modifications and additions to the # file, is the same license as for the pristine package itself (unless the # license for the pristine package is not an Open Source License, in which # case the license is the MIT License). An "Open Source License" is a # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. # Please submit bugfixes or comments via http://bugs.opensuse.org/ # Name: python-magic %define build_python_bindings 1 BuildRequires: findutils BuildRequires: libtool BuildRequires: python-devel BuildRequires: zlib-devel Url: http://www.darwinsys.com/file/ Version: 5.11 Release: 0 Summary: Python module to use libmagic License: BSD-3-Clause and BSD-4-Clause Group: Development/Languages/Python %py_requires Source99: file.spec %{expand:%(sed -n -e '/^Source:/,/^BuildRoot:/p' <%_sourcedir/file.spec)} %global _sysconfdir /etc %global _miscdir %{_datadir}/misc %description This package contains the python binding that require the magic "file" interface. %prep %{expand:%(sed -n -e '/^%%prep/,/^%%install/p' <%_sourcedir/file.spec | sed -e '1d' -e '$d')} %install pushd python python setup.py install --root=%{buildroot} \ --prefix=%{_prefix} \ --record-rpm=../python_files popd %files -f python_files %defattr(-,root,root) %doc python/README python/example.py %changelog ++++++ 0001-PR-313-Aaron-Reffett-Check-properly-for-exceeding-th.patch ++++++ Based on 447558595a3650db2886cd2f416ad0beba965801 Mon Sep 17 00:00:00 2001 From: Christos ZoulasDate: Wed, 8 Jan 2014 22:22:54 +0000 Subject: [PATCH] PR/313: Aaron Reffett: Check properly for exceeding the offset. --- src/softmagic.c +++ src/softmagic.c 2014-03-04 16:12:17.954235635 +0000 @@ -60,6 +60,7 @@ private void cvt_16(union VALUETYPE *, c private void cvt_32(union VALUETYPE *, const struct magic *); private void cvt_64(union VALUETYPE *, const struct magic *); +#define OFFSET_OOB(n, o, i) ((n) < (o) || (i) >= ((n) - (o))) /* * softmagic - lookup one file in parsed, in-memory copy of database * Passed the name and FILE * of one file to be typed. @@ -1073,7 +1074,7 @@ mget(struct magic_set *ms, const unsigne } switch (m->in_type) { case FILE_BYTE: - if (nbytes < (offset + 1)) + if (OFFSET_OOB(nbytes, offset, 1)) return 0; if (off) { switch (m->in_op & FILE_OPS_MASK) { @@ -1108,7 +1109,7 @@ mget(struct magic_set *ms, const unsigne offset = ~offset; break; case FILE_BESHORT: - if (nbytes < (offset + 2)) + if (OFFSET_OOB(nbytes, offset, 2)) return 0; if (off) { switch (m->in_op & FILE_OPS_MASK) { @@ -1160,7 +1161,7 @@ mget(struct magic_set *ms, const unsigne offset = ~offset; break; case FILE_LESHORT: - if (nbytes < (offset + 2)) + if (OFFSET_OOB(nbytes, offset, 2)) return 0; if (off) { switch (m->in_op & FILE_OPS_MASK) { @@ -1212,7 +1213,7 @@ mget(struct magic_set *ms, const unsigne offset = ~offset; break; case FILE_SHORT: - if (nbytes < (offset + 2)) + if (OFFSET_OOB(nbytes, offset, 2)) return 0; if (off) { switch (m->in_op & FILE_OPS_MASK) { @@ -1249,7 +1250,7 @@ mget(struct magic_set *ms, const unsigne break; case FILE_BELONG: case FILE_BEID3: - if (nbytes < (offset + 4)) + if (OFFSET_OOB(nbytes, offset, 4)) return 0; if (off) { switch (m->in_op & FILE_OPS_MASK) { @@ -1320,7 +1321,7 @@ mget(struct magic_set *ms, const unsigne break; case FILE_LELONG: case FILE_LEID3: - if (nbytes < (offset + 4)) + if (OFFSET_OOB(nbytes, offset, 4)) return 0; if (off) { switch (m->in_op & FILE_OPS_MASK) { @@ -1390,7 +1391,7 @@ mget(struct magic_set *ms, const unsigne offset = ~offset; break; case FILE_MELONG: - if (nbytes < (offset + 4)) + if (OFFSET_OOB(nbytes, offset, 4)) return 0; if (off) { switch (m->in_op & FILE_OPS_MASK) { @@ -1460,7 +1461,7 @@ mget(struct magic_set *ms, const unsigne offset = ~offset; break; case FILE_LONG: - if (nbytes < (offset + 4)) + if (OFFSET_OOB(nbytes, offset, 4)) return 0; if (off) { switch (m->in_op & FILE_OPS_MASK) { @@ -1527,14 +1528,14 @@ mget(struct magic_set *ms, const unsigne /* Verify we have enough data to match magic type */ switch (m->type) { case FILE_BYTE: - if (nbytes < (offset + 1)) /* should alway be true */ + if (OFFSET_OOB(nbytes, offset, 1)) return 0; break; case FILE_SHORT: case FILE_BESHORT: case FILE_LESHORT: - if (nbytes < (offset + 2)) + if (OFFSET_OOB(nbytes, offset, 2)) return 0; break; @@ -1553,35 +1554,35 @@ mget(struct magic_set *ms, const unsigne case FILE_FLOAT: case FILE_BEFLOAT: case FILE_LEFLOAT: - if (nbytes < (offset + 4)) + if (OFFSET_OOB(nbytes, offset, 4)) return 0; break; case FILE_DOUBLE: case FILE_BEDOUBLE: case FILE_LEDOUBLE: - if (nbytes < (offset + 8)) + if (OFFSET_OOB(nbytes, offset, 8)) return 0; break; case FILE_STRING: case FILE_PSTRING: case FILE_SEARCH: - if (nbytes < (offset + m->vallen)) + if (OFFSET_OOB(nbytes, offset, m->vallen)) return 0; break; case FILE_REGEX: - if (nbytes < offset) + if (OFFSET_OOB(nbytes, offset, 0)) return 0; break; case FILE_INDIRECT: + if (OFFSET_OOB(nbytes, offset, 0)) + return 0; if ((ms->flags & (MAGIC_MIME|MAGIC_APPLE)) == 0 && file_printf(ms, "%s", m->desc) == -1) return -1; - if (nbytes < offset) - return 0; return file_softmagic(ms, s + offset, nbytes - offset, BINTEST, text); ++++++ 0001-prevent-infinite-recursion.patch ++++++ Based on 3c081560c23f20b2985c285338b52c7aae9fdb0f Mon Sep 17 00:00:00 2001 From: Christos Zoulas Date: Tue, 11 Feb 2014 15:41:25 +0000 Subject: [PATCH] prevent infinite recursion. --- src/softmagic.c +++ src/softmagic.c 2014-03-04 13:09:53.642735576 +0000 @@ -1578,6 +1578,8 @@ mget(struct magic_set *ms, const unsigne break; case FILE_INDIRECT: + if (offset == 0) + return 0; if (OFFSET_OOB(nbytes, offset, 0)) return 0; if ((ms->flags & (MAGIC_MIME|MAGIC_APPLE)) == 0 && ++++++ baselibs.conf ++++++ libmagic1 ++++++ file-4.03-tex.dif ++++++ --- magic/Localstuff +++ magic/Localstuff 2003-07-01 16:58:32.000000000 +0000 @@ -5,3 +5,12 @@ # $File: Localstuff,v 1.4 2003/03/23 04:17:27 christos Exp $ # Add any locally observed files here. Remember: # text if readable, executable if runnable binary, data if unreadable. + +# XXX promoted from tex so that *.tfm is not mis-identified as mc68k file. +# There is no way to detect TeX Font Metric (*.tfm) files without +# breaking them apart and reading the data. The following patterns +# match most *.tfm files generated by METAFONT or afm2tfm. +2 string \000\021 TeX font metric data +>33 string >\0 (%s) +2 string \000\022 TeX font metric data +>33 string >\0 (%s) ++++++ file-4.18-printf.dif ++++++ --- src/apprentice.c +++ src/apprentice.c 2006-11-22 16:09:57.000000000 +0000 @@ -886,8 +886,16 @@ quad = 1; /*FALLTHROUGH*/ case FILE_FMT_NUM: + if (*ptr == '#') + ptr++; + if (*ptr == ' ') + ptr++; if (*ptr == '-') ptr++; + if (*ptr == '+') + ptr++; + if (*ptr == '\'') + ptr++; if (*ptr == '.') ptr++; while (isdigit((unsigned char)*ptr)) ptr++; @@ -907,6 +915,7 @@ case 'i': case 'd': case 'u': + case 'o': case 'x': case 'X': return 0; @@ -921,12 +930,16 @@ case 'i': case 'd': case 'u': + case 'o': case 'x': case 'X': return 0; default: return -1; } + case 'o': + case 'x': + case 'X': case 'd': return 0; default: @@ -937,6 +950,7 @@ case 'c': case 'd': case 'u': + case 'o': case 'x': case 'X': return 0; ++++++ file-4.20-ssd.dif ++++++ --- magic/Localstuff +++ magic/Localstuff 2007-03-21 12:38:03.000000000 +0100 @@ -14,3 +14,12 @@ >33 string >\0 (%s) 2 string \000\022 TeX font metric data >33 string >\0 (%s) + +# XXX some MS Structured Storage Documents such as Adobe PageMaker[tm] +# files interfere with the Microsoft Office Document and the SSD starting +# sequence \320\317\021\340\241\261\032\341. Anyone who knows +# more details about the scheme of such SSDs and can help to extend this to all +# type of SSD, please let us know. E.g. how is the offset to the `Root Entry' +# determined? +512 search/531 R\0o\0o\0t\0\ \0E\0n\0t\0r\0y Structured Storage +>&109 search/17 P\0a\0g\0e\0M\0a\0k\0e\0r PageMaker ++++++ file-4.20-xen.dif ++++++ --- magic/Localstuff +++ magic/Localstuff 2007-03-21 12:41:52.000000000 +0100 @@ -23,3 +23,9 @@ # determined? 512 search/531 R\0o\0o\0t\0\ \0E\0n\0t\0r\0y Structured Storage >&109 search/17 P\0a\0g\0e\0M\0a\0k\0e\0r PageMaker + +# File magic for Xen, the virtual machine monitor for x86 +0 string LinuxGuestRecord Xen saved domain +#>2 regex \(name\ [^)]*\) %s +>20 search/256 (name (name +>>&1 string x %s...) ++++++ file-4.21-scribus.dif ++++++ --- magic/Localstuff +++ magic/Localstuff 2007-08-29 18:58:37.090251353 +0200 @@ -29,3 +29,7 @@ #>2 regex \(name\ [^)]*\) %s >20 search/256 (name (name >>&1 string x %s...) + +# File magic for Scribus, an Open Source Desktop Publishing system +0 string \ $@ -magic.${fsect}: Makefile magic.man +#magic.${fsect}: Makefile magic.man +magic.5: Makefile magic.man @rm -f $@ sed -e s@__CSECTION__@1@g \ -e s@__FSECTION__@${fsect}@g \ --- src/readelf.h +++ src/readelf.h 2003-07-01 14:53:55.000000000 +0000 @@ -34,7 +34,10 @@ #ifndef __fake_elf_h__ #define __fake_elf_h__ +#include + #if HAVE_STDINT_H +__BEGIN_DECLS #include #endif @@ -330,4 +333,5 @@ typedef struct { #define AV_386_SSE4_1 0x00800000 #define AV_386_SSE4_2 0x01000000 +__END_DECLS #endif ++++++ file-4.24-cromfs.dif ++++++ --- magic/Localstuff +++ magic/Localstuff 2008-04-14 16:59:45.741454927 +0200 @@ -36,3 +36,16 @@ # File magic for X11 cursor data files 0 string Xcur\020\000 X11 cursor data + +# File magic for CROM File System + +0 string CROMFS CROMFS +>6 string >\0 \b version %2.2s, +>8 ulequad >0 \b block data at %lld, +>16 ulequad >0 \b fblock table at %lld, +>24 ulequad >0 \b inode table at %lld, +>32 ulequad >0 \b root at %lld, +>40 ulelong >0 \b fblock size = %ld, +>44 ulelong >0 \b block size = %ld, +>48 ulequad >0 \b bytes = %lld + ++++++ file-4.24-mips.dif ++++++ --- magic/Magdir/elf +++ magic/Magdir/elf 2008-04-14 16:57:32.740393508 +0200 @@ -51,26 +51,26 @@ >>18 leshort 8 # only for 32-bit >>>4 byte 1 ->>>>36 lelong&0xf0000000 0x00000000 MIPS-I ->>>>36 lelong&0xf0000000 0x10000000 MIPS-II ->>>>36 lelong&0xf0000000 0x20000000 MIPS-III ->>>>36 lelong&0xf0000000 0x30000000 MIPS-IV ->>>>36 lelong&0xf0000000 0x40000000 MIPS-V ->>>>36 lelong&0xf0000000 0x50000000 MIPS32 ->>>>36 lelong&0xf0000000 0x60000000 MIPS64 ->>>>36 lelong&0xf0000000 0x70000000 MIPS32 rel2 ->>>>36 lelong&0xf0000000 0x80000000 MIPS64 rel2 +#>>>>36 lelong&0xf0000000 0x00000000 MIPS-I +#>>>>36 lelong&0xf0000000 0x10000000 MIPS-II +#>>>>36 lelong&0xf0000000 0x20000000 MIPS-III +#>>>>36 lelong&0xf0000000 0x30000000 MIPS-IV +#>>>>36 lelong&0xf0000000 0x40000000 MIPS-V +#>>>>36 lelong&0xf0000000 0x50000000 MIPS32 +#>>>>36 lelong&0xf0000000 0x60000000 MIPS64 +#>>>>36 lelong&0xf0000000 0x70000000 MIPS32 rel2 +#>>>>36 lelong&0xf0000000 0x80000000 MIPS64 rel2 # only for 64-bit >>>4 byte 2 ->>>>48 lelong&0xf0000000 0x00000000 MIPS-I ->>>>48 lelong&0xf0000000 0x10000000 MIPS-II ->>>>48 lelong&0xf0000000 0x20000000 MIPS-III ->>>>48 lelong&0xf0000000 0x30000000 MIPS-IV ->>>>48 lelong&0xf0000000 0x40000000 MIPS-V ->>>>48 lelong&0xf0000000 0x50000000 MIPS32 ->>>>48 lelong&0xf0000000 0x60000000 MIPS64 ->>>>48 lelong&0xf0000000 0x70000000 MIPS32 rel2 ->>>>48 lelong&0xf0000000 0x80000000 MIPS64 rel2 +#>>>>48 lelong&0xf0000000 0x00000000 MIPS-I +#>>>>48 lelong&0xf0000000 0x10000000 MIPS-II +#>>>>48 lelong&0xf0000000 0x20000000 MIPS-III +#>>>>48 lelong&0xf0000000 0x30000000 MIPS-IV +#>>>>48 lelong&0xf0000000 0x40000000 MIPS-V +#>>>>48 lelong&0xf0000000 0x50000000 MIPS32 +#>>>>48 lelong&0xf0000000 0x60000000 MIPS64 +#>>>>48 lelong&0xf0000000 0x70000000 MIPS32 rel2 +#>>>>48 lelong&0xf0000000 0x80000000 MIPS64 rel2 >>18 leshort 9 Amdahl - invalid byte order, >>18 leshort 10 MIPS (deprecated), >>18 leshort 11 RS6000 - invalid byte order, @@ -181,26 +181,26 @@ >>18 beshort 8 # only for 32-bit >>>4 byte 1 ->>>>36 belong&0xf0000000 0x00000000 MIPS-I ->>>>36 belong&0xf0000000 0x10000000 MIPS-II ->>>>36 belong&0xf0000000 0x20000000 MIPS-III ->>>>36 belong&0xf0000000 0x30000000 MIPS-IV ->>>>36 belong&0xf0000000 0x40000000 MIPS-V ->>>>36 belong&0xf0000000 0x50000000 MIPS32 ->>>>36 belong&0xf0000000 0x60000000 MIPS64 ->>>>36 belong&0xf0000000 0x70000000 MIPS32 rel2 ->>>>36 belong&0xf0000000 0x80000000 MIPS64 rel2 +#>>>>36 belong&0xf0000000 0x00000000 MIPS-I +#>>>>36 belong&0xf0000000 0x10000000 MIPS-II +#>>>>36 belong&0xf0000000 0x20000000 MIPS-III +#>>>>36 belong&0xf0000000 0x30000000 MIPS-IV +#>>>>36 belong&0xf0000000 0x40000000 MIPS-V +#>>>>36 belong&0xf0000000 0x50000000 MIPS32 +#>>>>36 belong&0xf0000000 0x60000000 MIPS64 +#>>>>36 belong&0xf0000000 0x70000000 MIPS32 rel2 +#>>>>36 belong&0xf0000000 0x80000000 MIPS64 rel2 # only for 64-bit >>>4 byte 2 ->>>>48 belong&0xf0000000 0x00000000 MIPS-I ->>>>48 belong&0xf0000000 0x10000000 MIPS-II ->>>>48 belong&0xf0000000 0x20000000 MIPS-III ->>>>48 belong&0xf0000000 0x30000000 MIPS-IV ->>>>48 belong&0xf0000000 0x40000000 MIPS-V ->>>>48 belong&0xf0000000 0x50000000 MIPS32 ->>>>48 belong&0xf0000000 0x60000000 MIPS64 ->>>>48 belong&0xf0000000 0x70000000 MIPS32 rel2 ->>>>48 belong&0xf0000000 0x80000000 MIPS64 rel2 +#>>>>48 belong&0xf0000000 0x00000000 MIPS-I +#>>>>48 belong&0xf0000000 0x10000000 MIPS-II +#>>>>48 belong&0xf0000000 0x20000000 MIPS-III +#>>>>48 belong&0xf0000000 0x30000000 MIPS-IV +#>>>>48 belong&0xf0000000 0x40000000 MIPS-V +#>>>>48 belong&0xf0000000 0x50000000 MIPS32 +#>>>>48 belong&0xf0000000 0x60000000 MIPS64 +#>>>>48 belong&0xf0000000 0x70000000 MIPS32 rel2 +#>>>>48 belong&0xf0000000 0x80000000 MIPS64 rel2 >>18 beshort 9 Amdahl, >>18 beshort 10 MIPS (deprecated), >>18 beshort 11 RS6000, ++++++ file-4.24-solv.dif ++++++ --- magic/Localstuff +++ magic/Localstuff 2008-11-27 13:16:49.734433208 +0100 @@ -49,3 +49,7 @@ >44 ulelong >0 \b block size = %ld, >48 ulequad >0 \b bytes = %lld +# libsatsolver solv file + +0 string SOLV Sat-solver solv file, +>4 belong x version %ld ++++++ file-4.24-warn.dif ++++++ --- src/apprentice.c +++ src/apprentice.c @@ -562,6 +562,7 @@ /* invalid search type, but no need to complain here */ break; } + return 0; } /* ++++++ file-5.02-javacheck.dif ++++++ --- magic/Magdir/cafebabe +++ magic/Magdir/cafebabe 2009-05-05 14:11:37.858402267 +0200 @@ -12,7 +12,7 @@ # (and use as a hack). Let's not use 18, because the Mach-O people # might add another one or two as time goes by... # -0 belong 0xcafebabe +0 belong 0xcafebabe cafebabe !:mime application/x-java-applet >4 belong >30 compiled Java class data, >>6 beshort x version %d. ++++++ file-5.07-biorad.dif ++++++ --- magic/Magdir/images +++ magic/Magdir/images 2011-06-14 14:09:58.779926039 +0000 @@ -583,6 +583,8 @@ # http://web.archive.org/web/20050317223257/www.cs.ubc.ca/spider/ladic/text/biorad.txt # Samples: http://www.loci.wisc.edu/software/sample-data 14 leshort <2 +>4 leshort >0 +>49 byte 0 >62 leshort <2 >>54 leshort 12345 Bio-Rad .PIC Image File >>>0 leshort >0 %hd x ++++++ file-5.07-clicfs.dif ++++++ --- magic/Localstuff +++ magic/Localstuff 2011-06-14 17:40:22.417764753 +0000 @@ -53,3 +53,11 @@ 0 string SOLV Sat-solver solv file, >4 belong x version %ld + +# coolo's clicfs + +0 string/b CLIC ClicFS +>4 byte x \b Version %c +>5 byte x \b%c +>6 long >0 +>>6 pstring/l >0 \b, Target "%s" ++++++ file-5.07-elf.dif ++++++ --- src/readelf.c +++ src/readelf.c 2011-06-14 13:58:06.424425742 +0000 @@ -678,7 +678,7 @@ core: default: if (xnh_type == NT_PRPSINFO && *flags & FLAGS_IS_CORE) { - size_t i, j; + size_t i, j, m = 0; unsigned char c; /* * Extract the program name. We assume @@ -690,7 +690,9 @@ core: * If the characters aren't all printable, * reject it. */ - for (i = 0; i < NOFFSETS; i++) { + if (os_style == OS_STYLE_SVR4) + m = 1; + for (i = m; i < NOFFSETS; i++) { unsigned char *cname, *cp; size_t reloffset = prpsoffsets(i); size_t noffset = doff + reloffset; ++++++ file-5.07-iso9660.dif ++++++ --- magic/Magdir/filesystems +++ magic/Magdir/filesystems 2009-10-27 15:55:38.000000000 +0000 @@ -1236,6 +1236,7 @@ 32769 string CD001 # !:mime application/x-iso9660-image >38913 string !NSR0 ISO 9660 CD-ROM filesystem data +!:mime application/x-iso9660-image >38913 string NSR0 UDF filesystem data >>38917 string 1 (version 1.0) >>38917 string 2 (version 1.5) ++++++ file-5.07-llvm.dif ++++++ --- magic/Magdir/llvm +++ magic/Magdir/llvm 2010-04-19 14:13:16.000000000 +0000 @@ -9,5 +9,8 @@ 0 string llvc0 LLVM byte-codes, null compression 0 string llvc1 LLVM byte-codes, gzip compression 0 string llvc2 LLVM byte-codes, bzip2 compression + +0 string BC\xc0\xde LLVM bitcode +0 string \xde\xc0\x17\x0b LLVM bitcode, wrapper 0 string \xde\xc0\x17\x0b LLVM bitcode, wrapper 0 string BC\xc0\xde LLVM bitcode ++++++ file-5.07-misc.dif ++++++ --- magic/Magdir/audio +++ magic/Magdir/audio 2008-04-14 14:17:59.000000000 +0000 @@ -129,7 +129,7 @@ # Oct 31, 1995 # fixed by 2003-06-24 # Too short... -#0 string MTM MultiTracker Module sound file +#0 string MTM MultiTracker Module sound data #0 string if Composer 669 Module sound data #0 string JN Composer 669 Module sound data (extended format) 0 string MAS_U ULT(imate) Module sound data --- magic/Magdir/bsdi +++ magic/Magdir/bsdi 2003-12-08 16:50:03.000000000 +0000 @@ -21,7 +21,7 @@ >32 byte 0x6a (uses shared libs) # same as in SunOS 4.x, except for static shared libraries -0 belong&077777777 0600413 sparc demand paged +0 belong&077777777 0600413 SPARC demand paged >0 byte &0x80 >>20 belong <4096 shared library >>20 belong =4096 dynamically linked executable @@ -30,13 +30,13 @@ >16 belong >0 not stripped >36 belong 0xb4100001 (uses shared libs) -0 belong&077777777 0600410 sparc pure +0 belong&077777777 0600410 SPARC pure >0 byte &0x80 dynamically linked executable >0 byte ^0x80 executable >16 belong >0 not stripped >36 belong 0xb4100001 (uses shared libs) -0 belong&077777777 0600407 sparc +0 belong&077777777 0600407 SPARC >0 byte &0x80 dynamically linked executable >0 byte ^0x80 executable >16 belong >0 not stripped --- magic/Magdir/mach +++ magic/Magdir/mach 2003-12-08 16:50:03.000000000 +0000 @@ -76,7 +76,7 @@ >4 belong 11 hppa >4 belong 12 acorn >4 belong 13 m88k ->4 belong 14 sparc +>4 belong 14 SPARC >4 belong 15 i860-big >4 belong 16 i860 >4 belong 17 rs6000 --- magic/Magdir/netbsd +++ magic/Magdir/netbsd 2003-12-08 16:50:03.000000000 +0000 @@ -102,25 +102,25 @@ 0 belong&0377777777 045200507 a.out NetBSD/powerpc core >12 string >\0 from '%s' -0 belong&0377777777 042400413 a.out NetBSD/sparc demand paged +0 belong&0377777777 042400413 a.out NetBSD/SPARC demand paged >0 byte &0x80 >>20 belong <8192 shared library >>20 belong =8192 dynamically linked executable >>20 belong >8192 dynamically linked executable >0 byte ^0x80 executable >16 belong >0 not stripped -0 belong&0377777777 042400410 a.out NetBSD/sparc pure +0 belong&0377777777 042400410 a.out NetBSD/SPARC pure >0 byte &0x80 dynamically linked executable >0 byte ^0x80 executable >16 belong >0 not stripped -0 belong&0377777777 042400407 a.out NetBSD/sparc +0 belong&0377777777 042400407 a.out NetBSD/SPARC >0 byte &0x80 dynamically linked executable >0 byte ^0x80 >>0 byte &0x40 position independent >>20 belong !0 executable >>20 belong =0 object file >16 belong >0 not stripped -0 belong&0377777777 042400507 a.out NetBSD/sparc core +0 belong&0377777777 042400507 a.out NetBSD/SPARC core >12 string >\0 from '%s' >32 belong !0 (signal %d) --- magic/Magdir/sun +++ magic/Magdir/sun 2006-11-22 14:49:20.000000000 +0000 @@ -6,7 +6,7 @@ # Values for big-endian Sun (MC680x0, SPARC) binaries on pre-5.x # releases. (5.x uses ELF.) # -0 belong&077777777 0600413 sparc demand paged +0 belong&077777777 0600413 SPARC demand paged >0 byte &0x80 >>20 belong <4096 shared library >>20 belong =4096 dynamically linked executable @@ -14,12 +14,12 @@ >0 byte ^0x80 executable >16 belong >0 not stripped -0 belong&077777777 0600410 sparc pure +0 belong&077777777 0600410 SPARC pure >0 byte &0x80 dynamically linked executable >0 byte ^0x80 executable >16 belong >0 not stripped -0 belong&077777777 0600407 sparc +0 belong&077777777 0600407 SPARC >0 byte &0x80 dynamically linked executable >0 byte ^0x80 executable >16 belong >0 not stripped ++++++ file-5.07-option.dif ++++++ --- src/file.c +++ src/file.c 2009-05-05 12:05:15.000000000 +0000 @@ -195,6 +195,8 @@ main(int argc, char *argv[]) flags |= MAGIC_DEBUG|MAGIC_CHECK; break; case 'e': + if (!optarg) + usage(); for (i = 0; i < sizeof(nv) / sizeof(nv[0]); i++) if (strcmp(nv[i].name, optarg) == 0) break; @@ -206,7 +208,7 @@ main(int argc, char *argv[]) break; case 'f': - if(action) + if(action || !optarg) usage(); if (magic == NULL) if ((magic = load(magicfile, flags)) == NULL) @@ -215,6 +217,8 @@ main(int argc, char *argv[]) ++didsomefiles; break; case 'F': + if (!optarg) + usage(); separator = optarg; break; case 'i': @@ -227,6 +231,8 @@ main(int argc, char *argv[]) action = FILE_LIST; break; case 'm': + if (!optarg) + usage(); magicfile = optarg; break; case 'n': ++++++ file-5.07-zip.dif ++++++ --- magic/Magdir/archive +++ magic/Magdir/archive 2011-07-18 09:56:50.651926085 +0000 @@ -571,6 +571,20 @@ # Zip archives (Greg Roelofs, c/o zip-bugs@wkuvx1.wku.edu) 0 string PK\003\004 +>30 ubelong !0x6d696d65 +>>4 byte 0x00 Zip archive data +!:mime application/zip +>>4 byte 0x09 Zip archive data, at least v0.9 to extract +!:mime application/zip +>>4 byte 0x0a Zip archive data, at least v1.0 to extract +!:mime application/zip +>>4 byte 0x0b Zip archive data, at least v1.1 to extract +!:mime application/zip +>>0x161 string WINZIP Zip archive data, WinZIP self-extracting +!:mime application/zip +>>4 byte 0x14 Zip archive data, at least v2.0 to extract +!:mime application/zip + # Specialised zip formats which start with a member named 'mimetype' # (stored uncompressed, with no 'extra field') containing the file's MIME type. ++++++ file-5.07-zip2.0.dif ++++++ --- magic/Magdir/archive +++ magic/Magdir/archive 2010-02-05 15:43:37.000000000 +0000 @@ -564,6 +564,10 @@ # PKZIP multi-volume archive 0 string PK\x07\x08PK\x03\x04 Zip multi-volume archive data, at least PKZIP v2.50 to extract !:mime application/zip +>>30 ubelong 0x6d696d65 Zip archive data, at least v2.0 to extract +>>>34 ubelong 0x74797065 \b, mime type +>>>>38 regex application/[a-z\+\-]+ \b %s +!:mime application/unknown+zip # Zip archives (Greg Roelofs, c/o zip-bugs@wkuvx1.wku.edu) 0 string PK\003\004 ++++++ file-5.10-visibility.patch ++++++ --- src/Makefile.am +++ src/Makefile.am 2012-01-16 13:23:27.235645838 +0000 @@ -11,7 +11,7 @@ libmagic_la_SOURCES = magic.c apprentice encoding.c compress.c is_tar.c readelf.c print.c fsmagic.c \ funcs.c file.h readelf.h tar.h apptype.c \ file_opts.h elfclass.h mygetopt.h cdf.c cdf_time.c readcdf.c cdf.h -libmagic_la_LDFLAGS = -no-undefined -version-info 1:0:0 +libmagic_la_LDFLAGS = -Wl,--version-script=$(srcdir)/libmagic.map -no-undefined -version-info 1:0:0 if MINGW MINGWLIBS = -lgnurx -lshlwapi else --- src/libmagic.map +++ src/libmagic.map 2011-06-14 00:00:00.000000000 +0000 @@ -0,0 +1,17 @@ +{ +global: + magic_buffer; + magic_check; + magic_close; + magic_compile; + magic_descriptor; + magic_errno; + magic_error; + magic_file; + magic_getpath; + magic_list; + magic_load; + magic_open; + magic_setflags; +local: *; +}; ++++++ file-5.10.dif ++++++ --- magic/Magdir/elf +++ magic/Magdir/elf 2006-11-22 14:57:15.000000000 +0000 @@ -102,7 +102,7 @@ >>18 leshort 47 Renesas H8/300H, >>18 leshort 48 Renesas H8S, >>18 leshort 49 Renesas H8/500, ->>18 leshort 50 IA-64, +>>18 leshort 50 IA-64 (Intel 64 bit architecture), >>18 leshort 51 Stanford MIPS-X, >>18 leshort 52 Motorola Coldfire, >>18 leshort 53 Motorola M68HC12, @@ -250,7 +250,7 @@ >>18 beshort 47 Renesas H8/300H, >>18 beshort 48 Renesas H8S, >>18 beshort 49 Renesas H8/500, ->>18 beshort 50 IA-64, +>>18 beshort 50 IA-64 (Intel 64 bit architecture), >>18 beshort 51 Stanford MIPS-X, >>18 beshort 52 Motorola Coldfire, >>18 beshort 53 Motorola M68HC12, --- magic/Magdir/linux +++ magic/Magdir/linux 2009-05-05 12:25:21.000000000 +0000 @@ -94,21 +94,43 @@ # and Nicol�s Lichtmaier # All known start with: b8 c0 07 8e d8 b8 00 90 8e c0 b9 00 01 29 f6 29 # Linux kernel boot images (i386 arch) (Wolfram Kleff) -514 string HdrS Linux kernel ->510 leshort 0xAA55 x86 boot executable ->>518 leshort >0x1ff ->>>529 byte 0 zImage, ->>>529 byte 1 bzImage, ->>>(526.s+0x200) string >\0 version %s, ->>498 leshort 1 RO-rootFS, ->>498 leshort 0 RW-rootFS, ->>508 leshort >0 root_dev 0x%X, ->>502 leshort >0 swap_dev 0x%X, ->>504 leshort >0 RAMdisksize %u KB, ->>506 leshort 0xFFFF Normal VGA ->>506 leshort 0xFFFE Extended VGA ->>506 leshort 0xFFFD Prompt for Videomode ->>506 leshort >0 Video mode %d +514 string HdrS Linux +>510 leshort 0xAA55 \b/x86 Kernel +>510 leshort <0xAA55 Kernel +>510 leshort >0xAA55 Kernel +>518 leshort 0x0105 \b, Setup Version 0x105, zImage +>518 leshort >0x0105 \b, Setup Version %#hx +>>529 byte 0 \b, zImage +>>529 byte 1 \b, bzImage +>>>(526.s+0x205) byte 32 +>>>>(526.s+0x200) string >\0 \b, Version %5.5s +>>>(526.s+0x206) byte 32 +>>>>(526.s+0x200) string >\0 \b, Version %6.6s +>>>(526.s+0x207) byte 32 +>>>>(526.s+0x200) string >\0 \b, Version %7.7s +>>>(526.s+0x205) byte 45 +>>>>(526.s+0x200) string >\0 \b, Version %5.5s +>>>(526.s+0x206) byte 45 +>>>>(526.s+0x200) string >\0 \b, Version %6.6s +>>>(526.s+0x207) byte 45 +>>>>(526.s+0x200) string >\0 \b, Version %7.7s +>>>(526.s+0x208) byte 45 +>>>>(526.s+0x200) string >\0 \b, Version %8.8s +>>>(526.s+0x209) byte 45 +>>>>(526.s+0x200) string >\0 \b, Version %9.9s +>>>(526.s+0x20a) byte 45 +>>>>(526.s+0x200) string >\0 \b, Version %10.10s +>>>(526.s+0x20b) byte 45 +>>>>(526.s+0x200) string >\0 \b, Version %11.11s +>>498 leshort 1 \b, RO-rootFS +>>498 leshort 0 \b, RW-rootFS +>>508 leshort >0 \b, root_dev 0x%X +>>502 leshort >0 \b, swap_dev 0x%X +>>504 leshort >0 \b, RAMdisksize %u KB +>>506 leshort 0xFFFF \b, Normal VGA +>>506 leshort 0xFFFE \b, Extended VGA +>>506 leshort 0xFFFD \b, Prompt for Videomode +>>506 leshort >0 \b, Video mode %d # This also matches new kernels, which were caught above by "HdrS". 0 belong 0xb8c0078e Linux kernel >0x1e3 string Loading version 1.3.79 or older --- magic/Magdir/msad +++ magic/Magdir/msad 2006-03-27 11:29:19.000000000 +0000 @@ -0,0 +1,5 @@ +#------------------------------------------------------------------------------ +# msad: file(1) magic for msad +# Microsoft visual C +# This must precede the heuristic for raw G3 data +4 string Standard\ Jet\ DB Microsoft Access Database --- magic/Magdir/msdos +++ magic/Magdir/msdos 2011-06-14 14:36:26.000000000 +0000 @@ -98,9 +98,9 @@ >>>(0x3c.l+22) leshort&0x0200 >0 (stripped to external PDB) >>>(0x3c.l+22) leshort&0x1000 >0 system file >>>(0x3c.l+24) leshort 0x010b ->>>>(0x3c.l+232) lelong >0 Mono/.Net assembly +>>>>(0x3c.l+232) lelong >0 \b, Mono/.Net assembly >>>(0x3c.l+24) leshort 0x020b ->>>>(0x3c.l+248) lelong >0 Mono/.Net assembly +>>>>(0x3c.l+248) lelong >0 \b, Mono/.Net assembly # hooray, there's a DOS extender using the PE format, with a valid PE # executable inside (which just prints a message and exits if run in win) --- magic/Makefile.am +++ magic/Makefile.am 2012-01-16 13:04:11.827645527 +0000 @@ -5,7 +5,7 @@ MAGIC_FRAGMENT_BASE = Magdir MAGIC_DIR = $(top_srcdir)/magic MAGIC_FRAGMENT_DIR = $(MAGIC_DIR)/$(MAGIC_FRAGMENT_BASE) -pkgdata_DATA = magic.mgc +pkgdata_DATA = magic.mgc magic EXTRA_DIST = \ $(MAGIC_DIR)/Header \ @@ -19,7 +19,6 @@ $(MAGIC_FRAGMENT_DIR)/amanda \ $(MAGIC_FRAGMENT_DIR)/amigaos \ $(MAGIC_FRAGMENT_DIR)/animation \ $(MAGIC_FRAGMENT_DIR)/apl \ -$(MAGIC_FRAGMENT_DIR)/apple \ $(MAGIC_FRAGMENT_DIR)/applix \ $(MAGIC_FRAGMENT_DIR)/archive \ $(MAGIC_FRAGMENT_DIR)/assembler \ @@ -71,7 +70,6 @@ $(MAGIC_FRAGMENT_DIR)/epoc \ $(MAGIC_FRAGMENT_DIR)/erlang \ $(MAGIC_FRAGMENT_DIR)/esri \ $(MAGIC_FRAGMENT_DIR)/fcs \ -$(MAGIC_FRAGMENT_DIR)/filesystems \ $(MAGIC_FRAGMENT_DIR)/flash \ $(MAGIC_FRAGMENT_DIR)/fonts \ $(MAGIC_FRAGMENT_DIR)/fortran \ @@ -106,20 +104,20 @@ $(MAGIC_FRAGMENT_DIR)/ispell \ $(MAGIC_FRAGMENT_DIR)/isz \ $(MAGIC_FRAGMENT_DIR)/java \ $(MAGIC_FRAGMENT_DIR)/jpeg \ +$(MAGIC_FRAGMENT_DIR)/linux \ +$(MAGIC_FRAGMENT_DIR)/filesystems \ $(MAGIC_FRAGMENT_DIR)/karma \ $(MAGIC_FRAGMENT_DIR)/kde \ $(MAGIC_FRAGMENT_DIR)/kml \ $(MAGIC_FRAGMENT_DIR)/lecter \ $(MAGIC_FRAGMENT_DIR)/lex \ $(MAGIC_FRAGMENT_DIR)/lif \ -$(MAGIC_FRAGMENT_DIR)/linux \ $(MAGIC_FRAGMENT_DIR)/lisp \ $(MAGIC_FRAGMENT_DIR)/llvm \ $(MAGIC_FRAGMENT_DIR)/lua \ $(MAGIC_FRAGMENT_DIR)/luks \ $(MAGIC_FRAGMENT_DIR)/m4 \ $(MAGIC_FRAGMENT_DIR)/mach \ -$(MAGIC_FRAGMENT_DIR)/macintosh \ $(MAGIC_FRAGMENT_DIR)/magic \ $(MAGIC_FRAGMENT_DIR)/mail.news \ $(MAGIC_FRAGMENT_DIR)/make \ @@ -138,10 +136,10 @@ $(MAGIC_FRAGMENT_DIR)/misctools \ $(MAGIC_FRAGMENT_DIR)/mkid \ $(MAGIC_FRAGMENT_DIR)/mlssa \ $(MAGIC_FRAGMENT_DIR)/mmdf \ -$(MAGIC_FRAGMENT_DIR)/modem \ $(MAGIC_FRAGMENT_DIR)/motorola \ $(MAGIC_FRAGMENT_DIR)/mozilla \ $(MAGIC_FRAGMENT_DIR)/msdos \ +$(MAGIC_FRAGMENT_DIR)/modem \ $(MAGIC_FRAGMENT_DIR)/msooxml \ $(MAGIC_FRAGMENT_DIR)/msvc \ $(MAGIC_FRAGMENT_DIR)/mup \ @@ -182,6 +180,8 @@ $(MAGIC_FRAGMENT_DIR)/pyramid \ $(MAGIC_FRAGMENT_DIR)/python \ $(MAGIC_FRAGMENT_DIR)/revision \ $(MAGIC_FRAGMENT_DIR)/riff \ +$(MAGIC_FRAGMENT_DIR)/apple \ +$(MAGIC_FRAGMENT_DIR)/macintosh \ $(MAGIC_FRAGMENT_DIR)/rinex \ $(MAGIC_FRAGMENT_DIR)/rpm \ $(MAGIC_FRAGMENT_DIR)/rtf \ @@ -248,8 +248,20 @@ $(MAGIC_FRAGMENT_DIR)/xwindows \ $(MAGIC_FRAGMENT_DIR)/zilog \ $(MAGIC_FRAGMENT_DIR)/zyxel +RAW = magic MAGIC = magic.mgc -CLEANFILES = ${MAGIC} $(MAGIC_FRAGMENT_DIR)/Localstuff +CLEANFILES = ${MAGIC} $(MAGIC_DIR)/Localstuff ${RAW} + +${RAW}: $(MAGIC_DIR)/Header $(MAGIC_DIR)/Localstuff $(EXTRA_DIST) + cat /dev/null > $@ + for frag in $(EXTRA_DIST); do \ + if test -f $(srcdir)/$$frag; then \ + f=$(srcdir)/$$frag; \ + else \ + f=$$frag; \ + fi; \ + cat $$f; \ + done >> $@ # FIXME: Build file natively as well so that it can be used to compile # the target's magic file; for now we bail if the local version does not match @@ -261,19 +273,22 @@ FILE_COMPILE = $(top_builddir)/src/file FILE_COMPILE_DEP = $(FILE_COMPILE) endif -${MAGIC}: $(EXTRA_DIST) $(FILE_COMPILE_DEP) - @rm -fr magic - @mkdir magic && cp -p $(EXTRA_DIST) magic - @(if expr "${FILE_COMPILE}" : '.*/.*' > /dev/null; then \ - echo "Using ${FILE_COMPILE} to generate ${MAGIC}" > /dev/null; \ - else \ - v=$$(file --version | sed -e s/file-// -e q); \ - if [ "$$v" != "${PACKAGE_VERSION}" ]; then \ - echo "Cannot use the installed version of file ($$v) to"; \ - echo "cross-compile file ${PACKAGE_VERSION}"; \ - echo "Please install file ${PACKAGE_VERSION} locally first"; \ - exit 1; \ - fi; \ - fi) - $(FILE_COMPILE) -C -m magic - @rm -fr magic +${MAGIC}: $(EXTRA_DIST) $(FILE_COMPILE_DEP) $(RAW) + $(FILE_COMPILE) -C -m $(RAW) + +#${MAGIC}: $(EXTRA_DIST) $(FILE_COMPILE_DEP) +# @rm -fr magic +# @mkdir magic && cp -p $(EXTRA_DIST) magic +# @(if expr "${FILE_COMPILE}" : '.*/.*' > /dev/null; then \ +# echo "Using ${FILE_COMPILE} to generate ${MAGIC}" > /dev/null; \ +# else \ +# v=$$(file --version | sed -e s/file-// -e q); \ +# if [ "$$v" != "${PACKAGE_VERSION}" ]; then \ +# echo "Cannot use the installed version of file ($$v) to"; \ +# echo "cross-compile file ${PACKAGE_VERSION}"; \ +# echo "Please install file ${PACKAGE_VERSION} locally first"; \ +# exit 1; \ +# fi; \ +# fi) +# $(FILE_COMPILE) -C -m magic +# @rm -fr magic --- magic/Makefile.in +++ magic/Makefile.in 2012-01-16 13:01:46.795146180 +0000 @@ -201,7 +201,7 @@ top_srcdir = @top_srcdir@ MAGIC_FRAGMENT_BASE = Magdir MAGIC_DIR = $(top_srcdir)/magic MAGIC_FRAGMENT_DIR = $(MAGIC_DIR)/$(MAGIC_FRAGMENT_BASE) -pkgdata_DATA = magic.mgc +pkgdata_DATA = magic.mgc magic EXTRA_DIST = \ $(MAGIC_DIR)/Header \ $(MAGIC_DIR)/Localstuff \ @@ -214,7 +214,6 @@ $(MAGIC_FRAGMENT_DIR)/amanda \ $(MAGIC_FRAGMENT_DIR)/amigaos \ $(MAGIC_FRAGMENT_DIR)/animation \ $(MAGIC_FRAGMENT_DIR)/apl \ -$(MAGIC_FRAGMENT_DIR)/apple \ $(MAGIC_FRAGMENT_DIR)/applix \ $(MAGIC_FRAGMENT_DIR)/archive \ $(MAGIC_FRAGMENT_DIR)/assembler \ @@ -266,7 +265,6 @@ $(MAGIC_FRAGMENT_DIR)/epoc \ $(MAGIC_FRAGMENT_DIR)/erlang \ $(MAGIC_FRAGMENT_DIR)/esri \ $(MAGIC_FRAGMENT_DIR)/fcs \ -$(MAGIC_FRAGMENT_DIR)/filesystems \ $(MAGIC_FRAGMENT_DIR)/flash \ $(MAGIC_FRAGMENT_DIR)/fonts \ $(MAGIC_FRAGMENT_DIR)/fortran \ @@ -301,20 +299,20 @@ $(MAGIC_FRAGMENT_DIR)/ispell \ $(MAGIC_FRAGMENT_DIR)/isz \ $(MAGIC_FRAGMENT_DIR)/java \ $(MAGIC_FRAGMENT_DIR)/jpeg \ +$(MAGIC_FRAGMENT_DIR)/linux \ +$(MAGIC_FRAGMENT_DIR)/filesystems \ $(MAGIC_FRAGMENT_DIR)/karma \ $(MAGIC_FRAGMENT_DIR)/kde \ $(MAGIC_FRAGMENT_DIR)/kml \ $(MAGIC_FRAGMENT_DIR)/lecter \ $(MAGIC_FRAGMENT_DIR)/lex \ $(MAGIC_FRAGMENT_DIR)/lif \ -$(MAGIC_FRAGMENT_DIR)/linux \ $(MAGIC_FRAGMENT_DIR)/lisp \ $(MAGIC_FRAGMENT_DIR)/llvm \ $(MAGIC_FRAGMENT_DIR)/lua \ $(MAGIC_FRAGMENT_DIR)/luks \ $(MAGIC_FRAGMENT_DIR)/m4 \ $(MAGIC_FRAGMENT_DIR)/mach \ -$(MAGIC_FRAGMENT_DIR)/macintosh \ $(MAGIC_FRAGMENT_DIR)/magic \ $(MAGIC_FRAGMENT_DIR)/mail.news \ $(MAGIC_FRAGMENT_DIR)/make \ @@ -333,10 +331,10 @@ $(MAGIC_FRAGMENT_DIR)/misctools \ $(MAGIC_FRAGMENT_DIR)/mkid \ $(MAGIC_FRAGMENT_DIR)/mlssa \ $(MAGIC_FRAGMENT_DIR)/mmdf \ -$(MAGIC_FRAGMENT_DIR)/modem \ $(MAGIC_FRAGMENT_DIR)/motorola \ $(MAGIC_FRAGMENT_DIR)/mozilla \ $(MAGIC_FRAGMENT_DIR)/msdos \ +$(MAGIC_FRAGMENT_DIR)/modem \ $(MAGIC_FRAGMENT_DIR)/msooxml \ $(MAGIC_FRAGMENT_DIR)/msvc \ $(MAGIC_FRAGMENT_DIR)/mup \ @@ -377,6 +375,8 @@ $(MAGIC_FRAGMENT_DIR)/pyramid \ $(MAGIC_FRAGMENT_DIR)/python \ $(MAGIC_FRAGMENT_DIR)/revision \ $(MAGIC_FRAGMENT_DIR)/riff \ +$(MAGIC_FRAGMENT_DIR)/apple \ +$(MAGIC_FRAGMENT_DIR)/macintosh \ $(MAGIC_FRAGMENT_DIR)/rinex \ $(MAGIC_FRAGMENT_DIR)/rpm \ $(MAGIC_FRAGMENT_DIR)/rtf \ @@ -443,10 +443,22 @@ $(MAGIC_FRAGMENT_DIR)/xwindows \ $(MAGIC_FRAGMENT_DIR)/zilog \ $(MAGIC_FRAGMENT_DIR)/zyxel +RAW = magic MAGIC = magic.mgc -CLEANFILES = ${MAGIC} $(MAGIC_FRAGMENT_DIR)/Localstuff +CLEANFILES = ${MAGIC} $(MAGIC_DIR)/Localstuff ${RAW} @IS_CROSS_COMPILE_FALSE@FILE_COMPILE = $(top_builddir)/src/file +${RAW}: $(MAGIC_DIR)/Header $(MAGIC_DIR)/Localstuff $(EXTRA_DIST) + cat /dev/null > $@ + for frag in $(EXTRA_DIST); do \ + if test -f $(srcdir)/$$frag; then \ + f=$(srcdir)/$$frag; \ + else \ + f=$$frag; \ + fi; \ + cat $$f; \ + done >> $@ + # FIXME: Build file natively as well so that it can be used to compile # the target's magic file; for now we bail if the local version does not match @IS_CROSS_COMPILE_TRUE@FILE_COMPILE = file @@ -661,23 +673,25 @@ uninstall-am: uninstall-pkgdataDATA mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ uninstall uninstall-am uninstall-pkgdataDATA +${MAGIC}: $(EXTRA_DIST) $(FILE_COMPILE_DEP) $(RAW) + $(FILE_COMPILE) -C -m $(RAW -${MAGIC}: $(EXTRA_DIST) $(FILE_COMPILE_DEP) - @rm -fr magic - @mkdir magic && cp -p $(EXTRA_DIST) magic - @(if expr "${FILE_COMPILE}" : '.*/.*' > /dev/null; then \ - echo "Using ${FILE_COMPILE} to generate ${MAGIC}" > /dev/null; \ - else \ - v=$$(file --version | sed -e s/file-// -e q); \ - if [ "$$v" != "${PACKAGE_VERSION}" ]; then \ - echo "Cannot use the installed version of file ($$v) to"; \ - echo "cross-compile file ${PACKAGE_VERSION}"; \ - echo "Please install file ${PACKAGE_VERSION} locally first"; \ - exit 1; \ - fi; \ - fi) - $(FILE_COMPILE) -C -m magic - @rm -fr magic +#${MAGIC}: $(EXTRA_DIST) $(FILE_COMPILE_DEP) +# @rm -fr magic +# @mkdir magic && cp -p $(EXTRA_DIST) magic +# @(if expr "${FILE_COMPILE}" : '.*/.*' > /dev/null; then \ +# echo "Using ${FILE_COMPILE} to generate ${MAGIC}" > /dev/null; \ +# else \ +# v=$$(file --version | sed -e s/file-// -e q); \ +# if [ "$$v" != "${PACKAGE_VERSION}" ]; then \ +# echo "Cannot use the installed version of file ($$v) to"; \ +# echo "cross-compile file ${PACKAGE_VERSION}"; \ +# echo "Please install file ${PACKAGE_VERSION} locally first"; \ +# exit 1; \ +# fi; \ +# fi) +# $(FILE_COMPILE) -C -m magic +# @rm -fr magic # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. --- src/Makefile.am +++ src/Makefile.am 2008-04-14 15:14:56.000000000 +0000 @@ -1,4 +1,4 @@ -MAGIC = $(pkgdatadir)/magic +MAGIC = $(sysconfdir)/magic:$(pkgdatadir)/magic lib_LTLIBRARIES = libmagic.la include_HEADERS = magic.h --- src/dcore.c +++ src/dcore.c 2006-03-27 11:29:19.000000000 +0000 @@ -0,0 +1,207 @@ +/* + * Show goo about ELF core files + * Jeremy Fitzhardinge 1996 + */ +#include +#include +#include +#include +#include +#include +#if defined __GLIBC__ && __GLIBC__ >= 2 +#include +#include +# ifndef NT_PRFPREG +# define NT_PRFPREG 2 +# endif +# ifndef NT_TASKSTRUCT +# define NT_TASKSTRUCT 4 +# endif +#else +#include +#include +#endif + +static void fperror(const char *str) +{ + perror(str); + exit(1); +} + +static size_t myread(int fd, void *buf, size_t sz) +{ + size_t ret; + + if ((ret = read(fd, buf, sz)) != sz) + fperror("read failed"); + return ret; +} + +static void print_prstatus(const prstatus_t *pr) +{ + unsigned i; + static const char *regs[] = { "ebx", "ecx", "edx", "esi", "edi", "ebp", + "eax", "ds", "es", "fs", "gs", + "orig_eax", "eip", "cs", + "efl", "uesp", "ss"}; + + printf(" pid=%d ppid=%d pgrp=%d sid=%d\n", + pr->pr_pid, pr->pr_ppid, pr->pr_pgrp, pr->pr_sid); + for(i = 0; i < NGREG; i++) + { + unsigned long val = pr->pr_reg[i]; + printf(" %-2u %-5s=%08lx %lu\n", i, regs[i], val, val); + } +} + +static void print_prpsinfo(const prpsinfo_t *ps) +{ + printf(" uid=%d gid=%d\n", ps->pr_uid, ps->pr_gid); + printf(" comm=%s\n", ps->pr_fname); + printf(" psargs=%s\n", ps->pr_psargs); +} + +#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) + +static void do_note(int fd, Elf32_Phdr *phdr) +{ + off_t here = lseek(fd, 0, SEEK_CUR); + int size = phdr->p_filesz; + char *raw = alloca(size), *end; + end = raw+size; + + lseek(fd, phdr->p_offset, SEEK_SET); + myread(fd, raw, size); + + while(raw < end) + { + Elf32_Nhdr *note = (Elf32_Nhdr *)raw; + const char *str; + const char *name, *desc; + + raw += sizeof(*note); + name = raw; + raw += roundup(note->n_namesz, sizeof(long)); + desc = raw; + raw += roundup(note->n_descsz, sizeof(long)); + + printf(" name=%.*s", (int)note->n_namesz, name); + + if(strncmp(name, "CORE", note->n_namesz) != 0) + { + printf("\n"); + continue; + } + + switch(note->n_type) + { +#define X(x) case x: str = #x; break; + X(NT_PRSTATUS); + X(NT_PRFPREG); + X(NT_PRPSINFO); + X(NT_TASKSTRUCT); +#undef X + default: + str = "???"; + } + printf(" n_type=%s n_descsz=%ld\n", + str, note->n_descsz); + switch(note->n_type) + { + case NT_PRSTATUS: + print_prstatus((prstatus_t *)desc); + break; + case NT_PRPSINFO: + print_prpsinfo((prpsinfo_t *)desc); + break; + } + } + lseek(fd, here, SEEK_SET); +} + +int main(int argc, char *argv[]) +{ + int fd; + Elf32_Ehdr elf; + int i; + + if (argc != 2) + { + fprintf(stderr, "Usage: %s corefile\n", argv[0]); + exit(1); + } + + if ((fd = open(argv[1], O_RDONLY)) == -1) + fperror("open of core"); + + myread(fd, &elf, sizeof(elf)); + + if (memcmp(ELFMAG, elf.e_ident, SELFMAG) != 0) + printf("bad magic\n"); + + if (elf.e_ident[EI_CLASS] != ELFCLASS32) + printf("wrong class\n"); + + if (elf.e_ident[EI_DATA] != ELFDATA2LSB) + printf("wrong endianess\n"); + + if (elf.e_ident[EI_VERSION] != EV_CURRENT) + printf("wrong version\n"); + + { + const char *str; + switch(elf.e_type) + { +#define C(x) case ET_##x: str = #x; break; + C(NONE); + C(REL); + C(EXEC); + C(DYN); + C(CORE); +#undef C + default: str = "???"; break; + } + printf("elf file type ET_%s\n", str); + } + + if (elf.e_machine != EM_386 && elf.e_machine != EM_486) + printf("not i386 or i486\n"); + + if (elf.e_ehsize != sizeof(elf)) + printf("wrong header size\n"); + + if (elf.e_phentsize != sizeof(Elf32_Phdr)) + printf("wrong phdr size\n"); + + if (lseek(fd, elf.e_phoff, SEEK_SET) != (off_t)elf.e_phoff) + fperror("lseek to phdr failed\n"); + + for(i = 0; i < elf.e_phnum; i++) + { + Elf32_Phdr phdr; + const char *str; + + myread(fd, &phdr, sizeof(phdr)); + switch(phdr.p_type) + { +#define C(x) case PT_##x: str = #x; break; + C(NULL); + C(LOAD); + C(DYNAMIC); + C(INTERP); + C(NOTE); + C(SHLIB); + C(PHDR); +#undef C + default: + str = "???"; break; + } + printf("type PT_%s off=%ld vaddr=%lx filesz=%ld flags=%lx\n", + str, phdr.p_offset, phdr.p_vaddr, phdr.p_filesz, + (unsigned long)phdr.p_flags); + if (phdr.p_type == PT_NOTE) + do_note(fd, &phdr); + } + exit(0); +} + ++++++ file-5.11-extfs-minix.dif ++++++ --- magic/Magdir/filesystems +++ magic/Magdir/filesystems 2012-11-26 15:19:17.434507842 +0000 @@ -881,44 +881,6 @@ # FATX 0 string FATX FATX filesystem data - -# Minix filesystems - Juan Cespedes -0x410 leshort 0x137f -!:strength / 2 ->0x402 beshort < 100 Minix filesystem, V1, %d zones ->0x1e string minix \b, bootable -0x410 beshort 0x137f -!:strength / 2 ->0x402 beshort < 100 Minix filesystem, V1 (big endian), %d zones ->0x1e string minix \b, bootable -0x410 leshort 0x138f -!:strength / 2 ->0x402 beshort < 100 Minix filesystem, V1, 30 char names, %d zones ->0x1e string minix \b, bootable -0x410 beshort 0x138f -!:strength / 2 ->0x402 beshort < 100 Minix filesystem, V1, 30 char names (big endian), %d zones ->0x1e string minix \b, bootable -0x410 leshort 0x2468 ->0x402 beshort < 100 Minix filesystem, V2, %d zones ->0x1e string minix \b, bootable -0x410 beshort 0x2468 ->0x402 beshort < 100 Minix filesystem, V2 (big endian), %d zones ->0x1e string minix \b, bootable - -0x410 leshort 0x2478 ->0x402 beshort < 100 Minix filesystem, V2, 30 char names, %d zones ->0x1e string minix \b, bootable -0x410 leshort 0x2478 ->0x402 beshort < 100 Minix filesystem, V2, 30 char names, %d zones ->0x1e string minix \b, bootable -0x410 beshort 0x2478 ->0x402 beshort !0 Minix filesystem, V2, 30 char names (big endian), %d zones ->0x1e string minix \b, bootable -0x410 leshort 0x4d5a ->0x402 beshort !0 Minix filesystem, V3, %d zones ->0x1e string minix \b, bootable - # romfs filesystems - Juan Cespedes 0 string -rom1fs- romfs filesystem, version 1 >8 belong x %d bytes, @@ -1157,6 +1119,44 @@ #>0x464 lelong &0x0000020 (many subdirs) #>0x463 lelong &0x0000040 (extra isize) + +# Minix filesystems - Juan Cespedes +0x410 leshort 0x137f +!:strength / 2 +>0x402 beshort < 100 Minix filesystem, V1, %d zones +>0x1e string minix \b, bootable +0x410 beshort 0x137f +!:strength / 2 +>0x402 beshort < 100 Minix filesystem, V1 (big endian), %d zones +>0x1e string minix \b, bootable +0x410 leshort 0x138f +!:strength / 2 +>0x402 beshort < 100 Minix filesystem, V1, 30 char names, %d zones +>0x1e string minix \b, bootable +0x410 beshort 0x138f +!:strength / 2 +>0x402 beshort < 100 Minix filesystem, V1, 30 char names (big endian), %d zones +>0x1e string minix \b, bootable +0x410 leshort 0x2468 +>0x402 beshort < 100 Minix filesystem, V2, %d zones +>0x1e string minix \b, bootable +0x410 beshort 0x2468 +>0x402 beshort < 100 Minix filesystem, V2 (big endian), %d zones +>0x1e string minix \b, bootable + +0x410 leshort 0x2478 +>0x402 beshort < 100 Minix filesystem, V2, 30 char names, %d zones +>0x1e string minix \b, bootable +0x410 leshort 0x2478 +>0x402 beshort < 100 Minix filesystem, V2, 30 char names, %d zones +>0x1e string minix \b, bootable +0x410 beshort 0x2478 +>0x402 beshort !0 Minix filesystem, V2, 30 char names (big endian), %d zones +>0x1e string minix \b, bootable +0x410 leshort 0x4d5a +>0x402 beshort !0 Minix filesystem, V3, %d zones +>0x1e string minix \b, bootable + # SGI disk labels - Nathan Scott 0 belong 0x0BE5A941 SGI disk label (volume header) ++++++ file-5.11-nitpick.dif ++++++ --- src/file.c +++ src/file.c 2012-09-18 10:27:51.094936322 +0000 @@ -94,10 +94,12 @@ private const char *separator = ":"; /* private const struct option long_options[] = { #define OPT(shortname, longname, opt, doc) \ {longname, opt, NULL, shortname}, +#define OPT_POSIX OPT #define OPT_LONGONLY(longname, opt, doc) \ {longname, opt, NULL, 0}, #include "file_opts.h" #undef OPT +#undef OPT_POSIX #undef OPT_LONGONLY {0, 0, NULL, 0} }; @@ -487,16 +489,21 @@ usage(void) private void help(void) { + const unsigned long posix = (unsigned long)getenv("POSIXLY_CORRECT"); (void)fputs( "Usage: file [OPTION...] [FILE...]\n" "Determine type of FILEs.\n" "\n", stdout); #define OPT(shortname, longname, opt, doc) \ fprintf(stdout, " -%c, --" longname doc, shortname); +#define OPT_POSIX(shortname, longname, opt, doc) \ + fprintf(stdout, " -%c, --" longname doc "%s\n", shortname, \ + (shortname == 'L') ? (posix ? " (default)" : "") : (posix ? "" : " (default)")); #define OPT_LONGONLY(longname, opt, doc) \ fprintf(stdout, " --" longname doc); #include "file_opts.h" #undef OPT +#undef OPT_POSIX #undef OPT_LONGONLY fprintf(stdout, "\nReport bugs to http://bugs.gw.com/\n"); exit(0); --- src/file_opts.h +++ src/file_opts.h 2012-09-18 10:14:38.438397131 +0000 @@ -34,8 +34,8 @@ OPT_LONGONLY("mime-encoding", 0, " OPT('k', "keep-going", 0, " don't stop at the first match\n") #ifdef S_IFLNK OPT('l', "list", 0, " list magic strength\n") -OPT('L', "dereference", 0, " follow symlinks (default)\n") -OPT('h', "no-dereference", 0, " don't follow symlinks\n") +OPT_POSIX('L', "dereference", 0, " follow symlinks") +OPT_POSIX('h', "no-dereference", 0, " don't follow symlinks") #endif OPT('n', "no-buffer", 0, " do not buffer output\n") OPT('N', "no-pad", 0, " do not pad output\n") ++++++ file-endian.patch ++++++ --- src/apprentice.c.orig +++ src/apprentice.c @@ -48,6 +48,7 @@ FILE_RCSID("@(#)$File: apprentice.c,v 1. #include #endif #include +#include #define EATAB {while (isascii((unsigned char) *l) && \ isspace((unsigned char) *l)) ++l;} @@ -97,9 +98,11 @@ private int apprentice_load(struct magic const char *, int); private void byteswap(struct magic *, uint32_t); private void bs1(struct magic *); -private uint16_t swap2(uint16_t); -private uint32_t swap4(uint32_t); -private uint64_t swap8(uint64_t); + +#define swap2(x) bswap_16(x) +#define swap4(x) bswap_32(x) +#define swap8(x) bswap_64(x) + private char *mkdbname(struct magic_set *, const char *, int); private int apprentice_map(struct magic_set *, struct magic **, uint32_t *, const char *); @@ -662,7 +665,7 @@ set_test_type(struct magic *mstart, stru /* invalid search type, but no need to complain here */ break; } - return 0; + //return 0; } /* @@ -2412,67 +2415,6 @@ byteswap(struct magic *magic, uint32_t n } /* - * swap a short - */ -private uint16_t -swap2(uint16_t sv) -{ - uint16_t rv; - uint8_t *s = (uint8_t *)(void *)&sv; - uint8_t *d = (uint8_t *)(void *)&rv; - d[0] = s[1]; - d[1] = s[0]; - return rv; -} - -/* - * swap an int - */ -private uint32_t -swap4(uint32_t sv) -{ - uint32_t rv; - uint8_t *s = (uint8_t *)(void *)&sv; - uint8_t *d = (uint8_t *)(void *)&rv; - d[0] = s[3]; - d[1] = s[2]; - d[2] = s[1]; - d[3] = s[0]; - return rv; -} - -/* - * swap a quad - */ -private uint64_t -swap8(uint64_t sv) -{ - uint64_t rv; - uint8_t *s = (uint8_t *)(void *)&sv; - uint8_t *d = (uint8_t *)(void *)&rv; -#if 0 - d[0] = s[3]; - d[1] = s[2]; - d[2] = s[1]; - d[3] = s[0]; - d[4] = s[7]; - d[5] = s[6]; - d[6] = s[5]; - d[7] = s[4]; -#else - d[0] = s[7]; - d[1] = s[6]; - d[2] = s[5]; - d[3] = s[4]; - d[4] = s[3]; - d[5] = s[2]; - d[6] = s[1]; - d[7] = s[0]; -#endif - return rv; -} - -/* * byteswap a single magic entry */ private void --- src/cdf.c.orig +++ src/cdf.c @@ -50,6 +50,7 @@ FILE_RCSID("@(#)$File: cdf.c,v 1.50 2012 #ifdef HAVE_LIMITS_H #include #endif +#include #ifndef EFTYPE #define EFTYPE EINVAL @@ -75,56 +76,9 @@ static union { #define CDF_TOLE2(x) ((uint16_t)(NEED_SWAP ? _cdf_tole2(x) : (uint16_t)(x))) #define CDF_GETUINT32(x, y) cdf_getuint32(x, y) - -/* - * swap a short - */ -static uint16_t -_cdf_tole2(uint16_t sv) -{ - uint16_t rv; - uint8_t *s = (uint8_t *)(void *)&sv; - uint8_t *d = (uint8_t *)(void *)&rv; - d[0] = s[1]; - d[1] = s[0]; - return rv; -} - -/* - * swap an int - */ -static uint32_t -_cdf_tole4(uint32_t sv) -{ - uint32_t rv; - uint8_t *s = (uint8_t *)(void *)&sv; - uint8_t *d = (uint8_t *)(void *)&rv; - d[0] = s[3]; - d[1] = s[2]; - d[2] = s[1]; - d[3] = s[0]; - return rv; -} - -/* - * swap a quad - */ -static uint64_t -_cdf_tole8(uint64_t sv) -{ - uint64_t rv; - uint8_t *s = (uint8_t *)(void *)&sv; - uint8_t *d = (uint8_t *)(void *)&rv; - d[0] = s[7]; - d[1] = s[6]; - d[2] = s[5]; - d[3] = s[4]; - d[4] = s[3]; - d[5] = s[2]; - d[6] = s[1]; - d[7] = s[0]; - return rv; -} +#define _cdf_tole2(x) bswap_16(x) +#define _cdf_tole4(x) bswap_32(x) +#define _cdf_tole8(x) bswap_64(x) /* * grab a uint32_t from a possibly unaligned address, and return it in ++++++ file-ocloexec.patch ++++++ --- src/compress.c.orig +++ src/compress.c @@ -256,7 +256,7 @@ file_pipe2file(struct magic_set *ms, int errno = r; } #else - tfd = mkstemp(buf); + tfd = mkostemp(buf, O_CLOEXEC); te = errno; (void)unlink(buf); errno = te; --- src/apprentice.c.orig +++ src/apprentice.c @@ -676,7 +676,7 @@ load_1(struct magic_set *ms, int action, char *line = NULL; ssize_t len; - FILE *f = fopen(ms->file = fn, "r"); + FILE *f = fopen(ms->file = fn, "re"); if (f == NULL) { if (errno != ENOENT) file_error(ms, errno, "cannot read magic file `%s'", @@ -2226,7 +2226,7 @@ apprentice_map(struct magic_set *ms, str if (dbname == NULL) goto error2; - if ((fd = open(dbname, O_RDONLY|O_BINARY)) == -1) + if ((fd = open(dbname, O_RDONLY|O_BINARY|O_CLOEXEC)) == -1) goto error2; if (fstat(fd, &st) == -1) { @@ -2324,7 +2324,7 @@ apprentice_compile(struct magic_set *ms, if (dbname == NULL) goto out; - if ((fd = open(dbname, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0644)) == -1) { + if ((fd = open(dbname, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY|O_CLOEXEC, 0644)) == -1) { file_error(ms, errno, "cannot open `%s'", dbname); goto out; } --- src/magic.c.orig +++ src/magic.c @@ -411,7 +411,7 @@ file_or_fd(struct magic_set *ms, const c if (fstat(fd, &sb) == 0 && S_ISFIFO(sb.st_mode)) ispipe = 1; } else { - int flags = O_RDONLY|O_BINARY; + int flags = O_RDONLY|O_BINARY|O_CLOEXEC; if (stat(inname, &sb) == 0 && S_ISFIFO(sb.st_mode)) { #ifdef O_NONBLOCK --- src/file.c.orig +++ src/file.c @@ -385,7 +385,7 @@ unwrap(struct magic_set *ms, const char f = stdin; wid = 1; } else { - if ((f = fopen(fn, "r")) == NULL) { + if ((f = fopen(fn, "re")) == NULL) { (void)fprintf(stderr, "%s: Cannot open `%s' (%s).\n", progname, fn, strerror(errno)); return 1; ++++++ pre_checkin.sh ++++++ #!/bin/bash # This script is called automatically during autobuild checkin. version=$(grep '^Version:.*' file.spec) sed -ri "s,^Version:.*,$version," python-magic.spec -- To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-commit+help@opensuse.org