[packages/file] fix mach-o file crash

glen glen at pld-linux.org
Mon Mar 18 10:14:51 CET 2013


commit 81246df60908e16bc21dcef266c84cac7352583c
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Mon Mar 18 11:13:40 2013 +0200

    fix mach-o file crash
    
    $ file embedded/rgloader/rgloader.darwin.bundle
    embedded/rgloader/rgloader.darwin.bundle: Mach-O universal binary with 3 architectures: [ I386: Mach-O i386 bundle ] [ X86_64: Mach-O 64-bit x86_64 bundle ] [ : Mach-O ppc bundle ] [ ]
    $ rpm -q file
    file-5.13-1.1.x86_64

 file.spec         | 18 +++---------------
 macho-crash.patch | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 15 deletions(-)
---
diff --git a/file.spec b/file.spec
index a682e98..868b65a 100644
--- a/file.spec
+++ b/file.spec
@@ -1,17 +1,3 @@
-#!!!!!!!!!!!!!!!!!!!
-TODO:
-
-file /home/users/glen/tmp/vagrant-1.1.0-root-glen/usr/lib64/vagrant/embedded/rgloader/rgloader.darwin.bundle
-Segmentation fault
-glen at carme-pld packages/vagrant $ q file
-file-5.13-1.x86_64
-
-glen at carme-pld packages/vagrant $ file /home/users/glen/tmp/vagrant-1.1.0-root-glen/usr/lib64/vagrant/embedded/rgloader/rgloader.darwin.bundle
-/home/users/glen/tmp/vagrant-1.1.0-root-glen/usr/lib64/vagrant/embedded/rgloader/rgloader.darwin.bundle: ERROR: Mach-O fat file with 3 architectures: [ I386
-glen at carme-pld packages/vagrant $ q file
-file-5.12-1.x86_64
-#!!!!!!!!!!!!!!!!!!!!
-
 #
 # Conditional build:
 %bcond_without	python		# don't build python-magic module
@@ -43,7 +29,7 @@ Summary(zh_CN.UTF-8):	判定文件类型的工具。
 Summary(zh_TW.UTF-8):	用於決定檔案類型的一個工具程式。
 Name:		file
 Version:	5.13
-Release:	1.1
+Release:	2
 License:	distributable
 Group:		Applications/File
 Source0:	ftp://ftp.astron.com/pub/file/%{name}-%{version}.tar.gz
@@ -59,6 +45,7 @@ Patch2:		searchpath.patch
 Patch3:		automake.patch
 Patch4:		sticky-bit.patch
 Patch5:		cdf-pread.patch
+Patch6:		macho-crash.patch
 URL:		http://www.darwinsys.com/file/
 BuildRequires:	autoconf >= 2.50
 BuildRequires:	automake
@@ -268,6 +255,7 @@ Wiązania Pythona dla libmagic.
 %patch3 -p1
 %patch4 -p1
 %patch5 -p1
+%patch6 -p1
 
 %if "%{cc_version}" < "3.4"
 %{__sed} -i -e 's,-Wextra,,' configure.ac
diff --git a/macho-crash.patch b/macho-crash.patch
new file mode 100644
index 0000000..69f3957
--- /dev/null
+++ b/macho-crash.patch
@@ -0,0 +1,33 @@
+See file mailinglist thread:
+http://mx.gw.com/pipermail/file/2013/001138.html
+
+From cf289f23851ba3eb017576be1ba65c0a0f0e16a9 Mon Sep 17 00:00:00 2001
+From: Christos Zoulas <christos at zoulas.com>
+Date: Tue, 26 Feb 2013 18:24:43 +0000
+Subject: [PATCH] - avoid 0 offset causing an infinite loop. - XXX: should
+ limit indirect nesting.
+
+---
+ src/softmagic.c | 8 +++++++-
+ 1 file changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/src/softmagic.c b/src/softmagic.c
+index c42ca19..22d1a27 100644
+--- a/src/softmagic.c
++++ b/src/softmagic.c
+@@ -1617,6 +1617,12 @@ private int mcopy(struct magic_set *, union VALUETYPE *, int, int,
+ 
+ 		if (m->flag & INDIROFFADD) {
+ 			offset += ms->c.li[cont_level-1].off;
++			if (offset == 0) {
++				if ((ms->flags & MAGIC_DEBUG) != 0)
++					fprintf(stderr,
++					    "indirect *zero* offset\n");
++				return 0;
++			}
+ 			if ((ms->flags & MAGIC_DEBUG) != 0)
+ 				fprintf(stderr, "indirect +offs=%u\n", offset);
+ 		}
+-- 
+1.8.1.5
+
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/file.git/commitdiff/81246df60908e16bc21dcef266c84cac7352583c



More information about the pld-cvs-commit mailing list