fix #847936 - decompress bzip2 properly when using -z param

- fix #847937 - read magic patterns also from ~/.magic.mgc
This commit is contained in:
Jan Kaluza 2012-08-14 08:00:15 +02:00
parent 12c410d7bb
commit 00331f323b
3 changed files with 54 additions and 1 deletions

13
file-5.11-compress.patch Normal file
View File

@ -0,0 +1,13 @@
diff --git a/src/compress.c b/src/compress.c
index 2b05352..ccb1cfd 100644
--- a/src/compress.c
+++ b/src/compress.c
@@ -183,7 +183,7 @@ sread(int fd, void *buf, size_t n, int canbepipe __attribute__ ((unused)))
goto nocheck;
#ifdef FIONREAD
- if ((canbepipe && (ioctl(fd, FIONREAD, &t) == -1)) || (t == 0)) {
+ if (canbepipe && ((ioctl(fd, FIONREAD, &t) == -1) || (t == 0))) {
#ifdef FD_ZERO
for (cnt = 0;; cnt++) {
fd_set check;

View File

@ -0,0 +1,32 @@
diff --git a/src/magic.c b/src/magic.c
index 7eb0441..d8c5835 100644
--- a/src/magic.c
+++ b/src/magic.c
@@ -101,16 +101,20 @@ get_default_magic(void)
if ((home = getenv("HOME")) == NULL)
return MAGIC;
- if (asprintf(&hmagicpath, "%s/.magic", home) < 0)
+ if (asprintf(&hmagicpath, "%s/.magic.mgc", home) < 0)
return MAGIC;
- if (stat(hmagicpath, &st) == -1)
- goto out;
- if (S_ISDIR(st.st_mode)) {
- free(hmagicpath);
- if (asprintf(&hmagicpath, "%s/%s", home, hmagic) < 0)
+ if (stat(hmagicpath, &st) == -1) {
+ if (asprintf(&hmagicpath, "%s/.magic", home) < 0)
return MAGIC;
- if (access(hmagicpath, R_OK) == -1)
+ if (stat(hmagicpath, &st) == -1)
goto out;
+ if (S_ISDIR(st.st_mode)) {
+ free(hmagicpath);
+ if (asprintf(&hmagicpath, "%s/%s", home, hmagic) < 0)
+ return MAGIC;
+ if (access(hmagicpath, R_OK) == -1)
+ goto out;
+ }
}
if (asprintf(&default_magic, "%s:%s", hmagicpath, MAGIC) < 0)

View File

@ -5,7 +5,7 @@
Summary: A utility for determining file types
Name: file
Version: 5.11
Release: 4%{?dist}
Release: 5%{?dist}
License: BSD
Group: Applications/File
Source0: ftp://ftp.astron.com/pub/file/file-%{version}.tar.gz
@ -19,6 +19,8 @@ Patch4: file-python-func.patch
Patch5: file-qed-vdi-image.patch
Patch6: file-5.11-ia64-swap.patch
Patch7: file-4.17-rpm-name.patch
Patch8: file-5.11-magicmgc-home.patch
Patch9: file-5.11-compress.patch
URL: http://www.darwinsys.com/file/
Requires: file-libs = %{version}-%{release}
BuildRequires: zlib-devel
@ -79,6 +81,8 @@ file(1) command.
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
iconv -f iso-8859-1 -t utf-8 < doc/libmagic.man > doc/libmagic.man_
touch -r doc/libmagic.man doc/libmagic.man_
@ -154,6 +158,10 @@ cd python
%endif
%changelog
* Tue Aug 14 2012 Jan Kaluza <jkaluza@redhat.com> - 5.11-5
- fix #847936 - decompress bzip2 properly when using -z param
- fix #847937 - read magic patterns also from ~/.magic.mgc
* Fri Jul 27 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 5.11-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild