This commit is contained in:
Daniel Novotny 2008-10-16 11:01:33 +00:00
parent 8b1b06a030
commit 0f023a0e68
2 changed files with 55 additions and 3 deletions

View File

@ -0,0 +1,46 @@
diff -up file-4.26/src/funcs.c.mime file-4.26/src/funcs.c
--- file-4.26/src/funcs.c.mime 2008-10-14 13:07:44.000000000 +0200
+++ file-4.26/src/funcs.c 2008-10-16 11:47:01.000000000 +0200
@@ -152,6 +152,20 @@ file_badread(struct magic_set *ms)
file_error(ms, errno, "error reading");
}
+private int mime_encoding(struct magic_set * ms, const unsigned char * buf, size_t size)
+{
+size_t dummy;
+
+if( file_looks_utf8(buf, size, NULL, &dummy) == 1 )
+{
+ if(file_printf(ms, "7bit") == -1)
+ return -1;
+} else if(file_printf(ms, "binary") == -1)
+ return -1;
+
+return 1;
+}
+
#ifndef COMPILE_ONLY
protected int
file_buffer(struct magic_set *ms, int fd, const char *inname, const void *buf,
@@ -187,6 +201,8 @@ file_buffer(struct magic_set *ms, int fd
}
}
#endif
+ if (ms->flags & MAGIC_MIME_ENCODING && !(ms->flags & MAGIC_MIME_TYPE))
+ return mime_encoding(ms, ubuf, nb);
/* try compression stuff */
if ((ms->flags & MAGIC_NO_CHECK_COMPRESS) != 0 ||
@@ -206,9 +222,9 @@ file_buffer(struct magic_set *ms, int fd
"data") == -1)
return -1;
m = 1;
- }
- }
- }
+ }
+ }
+ }
}
#ifdef BUILTIN_ELF
if ((ms->flags & MAGIC_NO_CHECK_ELF) == 0 && m == 1 &&

View File

@ -5,13 +5,14 @@
Summary: A utility for determining file types
Name: file
Version: 4.26
Release: 2%{?dist}
Release: 3%{?dist}
License: BSD
Group: Applications/File
Source0: ftp://ftp.astron.com/pub/file/file-%{version}.tar.gz
URL: http://www.darwinsys.com/file/
patch0: file-4.21-pybuild.patch
patch1: file-4.26-devdrv.patch
Patch0: file-4.21-pybuild.patch
Patch1: file-4.26-devdrv.patch
Patch2: file-4.26-mime-encoding.patch
Requires: file-libs = %{version}-%{release}
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@ -60,6 +61,8 @@ file(1) command.
%patch0 -p1
#fixes #463809
%patch1 -p1
#fixes #465994
%patch2 -p1
iconv -f iso-8859-1 -t utf-8 < doc/libmagic.man > doc/libmagic.man_
touch -r doc/libmagic.man doc/libmagic.man_
@ -133,6 +136,9 @@ rm -rf $RPM_BUILD_ROOT
%endif
%changelog
* Thu Oct 16 2008 Daniel Novotny <dnovotny@redhat.com> 4.26-3
- fix #465994 file --mime-encoding seems broken
* Tue Oct 07 2008 Daniel Novotny <dnovotny@redhat.com> 4.26-2
- fix #463809: rpmbuild rpmfcClassify: Assertion fails on some binary files
(false positive test on "DOS device driver" crashed file(1)