summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristos Zoulas <christos@zoulas.com>2005-01-07 19:17:24 +0000
committerChristos Zoulas <christos@zoulas.com>2005-01-07 19:17:24 +0000
commit078e11ce780213f6bb34a4be320bfcbd86ff2424 (patch)
treed055ca922de2c34c060bf5fca59e8fb308438d58
parent66255bcfe69c93d7c6ef44baa192cf9bcc5d61ad (diff)
downloadfile-git-078e11ce780213f6bb34a4be320bfcbd86ff2424.tar.gz
Fix bzip2 issue
-rw-r--r--ChangeLog8
-rw-r--r--Makefile.in11
-rw-r--r--aclocal.m437
-rwxr-xr-xconfigure44
-rw-r--r--doc/Makefile.in5
-rw-r--r--magic/Makefile.in5
-rw-r--r--magic/magic.mime2
-rw-r--r--python/Makefile.in5
-rw-r--r--src/Makefile.in4
-rw-r--r--src/compress.c97
-rw-r--r--src/file.h6
-rw-r--r--src/funcs.c6
-rw-r--r--src/magic.c6
13 files changed, 179 insertions, 57 deletions
diff --git a/ChangeLog b/ChangeLog
index c7ca5450..62143e10 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2004-12-07 14:15 Christos Zoulas <christos@zoulas.com>
+
+ * bzip2 needs a lot of input buffer space on some files
+ before it can begin uncompressing. This makes file -z
+ fail on some bz2 files. Fix it by giving it a copy of
+ the file descriptor to read as much as it wants if we
+ have access to it. <christos@zoulas.com>
+
2004-11-24 12:39 Christos Zoulas <christos@zoulas.com>
* Stack smash fix, and ELF more conservative reading.
diff --git a/Makefile.in b/Makefile.in
index 33f9e83c..99dcdb82 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -75,6 +75,7 @@ ECHO = @ECHO@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
+MAINT = @MAINT@
OBJDUMP = @OBJDUMP@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
@@ -116,18 +117,18 @@ all: config.h
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
configure.lineno
-$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && \
$(AUTOMAKE) --foreign Makefile
-Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)
$(top_builddir)/config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
$(SHELL) ./config.status --recheck
-$(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
+$(srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
cd $(srcdir) && $(AUTOCONF)
-$(ACLOCAL_M4): configure.in acinclude.m4
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ configure.in acinclude.m4
cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
config.h: stamp-h1
@@ -140,7 +141,7 @@ stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
@rm -f stamp-h1
cd $(top_builddir) && $(SHELL) ./config.status config.h
-$(srcdir)/config.h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4)
+$(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOHEADER)
touch $(srcdir)/config.h.in
diff --git a/aclocal.m4 b/aclocal.m4
index 7b099095..8a868899 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1119,6 +1119,43 @@ AC_DEFUN([AM_CONFIG_HEADER],
[AC_FOREACH([_AM_File], [$1], [_AM_CONFIG_HEADER(_AM_File, [$2], [$3])])
])# AM_CONFIG_HEADER
+# Add --enable-maintainer-mode option to configure.
+# From Jim Meyering
+
+# Copyright 1996, 1998, 2000, 2001 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 1
+
+AC_DEFUN([AM_MAINTAINER_MODE],
+[AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
+ dnl maintainer-mode is disabled by default
+ AC_ARG_ENABLE(maintainer-mode,
+[ --enable-maintainer-mode enable make rules and dependencies not useful
+ (and sometimes confusing) to the casual installer],
+ USE_MAINTAINER_MODE=$enableval,
+ USE_MAINTAINER_MODE=no)
+ AC_MSG_RESULT([$USE_MAINTAINER_MODE])
+ AM_CONDITIONAL(MAINTAINER_MODE, [test $USE_MAINTAINER_MODE = yes])
+ MAINT=$MAINTAINER_MODE_TRUE
+ AC_SUBST(MAINT)dnl
+]
+)
+
# libtool.m4 - Configure libtool for the host system. -*-Shell-script-*-
# serial 46 AC_PROG_LIBTOOL
diff --git a/configure b/configure
index 26a1e14f..e5854d6f 100755
--- a/configure
+++ b/configure
@@ -990,6 +990,8 @@ if test -n "$ac_init_help"; then
Optional Features:
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
+ --enable-maintainer-mode enable make rules and dependencies not useful
+ (and sometimes confusing) to the casual installer
--disable-elf disable builtin ELF support
--disable-elf-core disable ELF core file support
--enable-fsect-man5 enable file formats in man section 5
@@ -1751,6 +1753,30 @@ ac_config_headers="$ac_config_headers config.h"
+echo "$as_me:$LINENO: checking whether to enable maintainer-specific portions of Makefiles" >&5
+echo $ECHO_N "checking whether to enable maintainer-specific portions of Makefiles... $ECHO_C" >&6
+ # Check whether --enable-maintainer-mode or --disable-maintainer-mode was given.
+if test "${enable_maintainer_mode+set}" = set; then
+ enableval="$enable_maintainer_mode"
+ USE_MAINTAINER_MODE=$enableval
+else
+ USE_MAINTAINER_MODE=no
+fi;
+ echo "$as_me:$LINENO: result: $USE_MAINTAINER_MODE" >&5
+echo "${ECHO_T}$USE_MAINTAINER_MODE" >&6
+
+
+if test $USE_MAINTAINER_MODE = yes; then
+ MAINTAINER_MODE_TRUE=
+ MAINTAINER_MODE_FALSE='#'
+else
+ MAINTAINER_MODE_TRUE='#'
+ MAINTAINER_MODE_FALSE=
+fi
+
+ MAINT=$MAINTAINER_MODE_TRUE
+
+
echo "$as_me:$LINENO: checking for builtin ELF support" >&5
echo $ECHO_N "checking for builtin ELF support... $ECHO_C" >&6
@@ -4328,7 +4354,7 @@ test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
case $host in
*-*-irix6*)
# Find out which ABI we are using.
- echo '#line 4331 "configure"' > conftest.$ac_ext
+ echo '#line 4357 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
@@ -4864,7 +4890,7 @@ chmod -w .
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -o out/conftest2.$ac_objext"
compiler_c_o=no
-if { (eval echo configure:4867: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then
+if { (eval echo configure:4893: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings
if test -s out/conftest.err; then
@@ -6657,7 +6683,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
-#line 6660 "configure"
+#line 6686 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -6755,7 +6781,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
-#line 6758 "configure"
+#line 6784 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -10983,6 +11009,13 @@ fi
DEFS=-DHAVE_CONFIG_H
+if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then
+ { { echo "$as_me:$LINENO: error: conditional \"MAINTAINER_MODE\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"MAINTAINER_MODE\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+ { (exit 1); exit 1; }; }
+fi
if test -z "${FSECT5_TRUE}" && test -z "${FSECT5_FALSE}"; then
{ { echo "$as_me:$LINENO: error: conditional \"FSECT5\" was never defined.
Usually this means the macro was only invoked conditionally." >&5
@@ -11508,6 +11541,9 @@ s,@ac_ct_STRIP@,$ac_ct_STRIP,;t t
s,@INSTALL_STRIP_PROGRAM@,$INSTALL_STRIP_PROGRAM,;t t
s,@AWK@,$AWK,;t t
s,@SET_MAKE@,$SET_MAKE,;t t
+s,@MAINTAINER_MODE_TRUE@,$MAINTAINER_MODE_TRUE,;t t
+s,@MAINTAINER_MODE_FALSE@,$MAINTAINER_MODE_FALSE,;t t
+s,@MAINT@,$MAINT,;t t
s,@fsect@,$fsect,;t t
s,@FSECT5_TRUE@,$FSECT5_TRUE,;t t
s,@FSECT5_FALSE@,$FSECT5_FALSE,;t t
diff --git a/doc/Makefile.in b/doc/Makefile.in
index 0810e5fc..cfa9ef65 100644
--- a/doc/Makefile.in
+++ b/doc/Makefile.in
@@ -75,6 +75,7 @@ ECHO = @ECHO@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
+MAINT = @MAINT@
OBJDUMP = @OBJDUMP@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
@@ -103,10 +104,10 @@ DIST_COMMON = Makefile.am Makefile.in
all: all-am
.SUFFIXES:
-$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu doc/Makefile
-Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
mostlyclean-libtool:
diff --git a/magic/Makefile.in b/magic/Makefile.in
index e5bd1731..0e78128b 100644
--- a/magic/Makefile.in
+++ b/magic/Makefile.in
@@ -75,6 +75,7 @@ ECHO = @ECHO@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
+MAINT = @MAINT@
OBJDUMP = @OBJDUMP@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
@@ -284,10 +285,10 @@ DIST_COMMON = Makefile.am Makefile.in
all: all-am
.SUFFIXES:
-$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu magic/Makefile
-Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
mostlyclean-libtool:
diff --git a/magic/magic.mime b/magic/magic.mime
index 5c484bf1..9be56467 100644
--- a/magic/magic.mime
+++ b/magic/magic.mime
@@ -202,7 +202,7 @@
# XPM icons (Greg Roelofs, newt@uchicago.edu)
# ideally should go into "images", but entries below would tag XPM as C source
-0 string /*\ XPM image/x-xpm 7bit
+0 string /*\ XPM image/x-xpmi 7bit
# 3DS (3d Studio files)
16 beshort 0x3d3d image/x-3ds
diff --git a/python/Makefile.in b/python/Makefile.in
index 06b11494..dd6322de 100644
--- a/python/Makefile.in
+++ b/python/Makefile.in
@@ -75,6 +75,7 @@ ECHO = @ECHO@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
+MAINT = @MAINT@
OBJDUMP = @OBJDUMP@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
@@ -95,10 +96,10 @@ DIST_COMMON = README Makefile.am Makefile.in
all: all-am
.SUFFIXES:
-$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu python/Makefile
-Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
mostlyclean-libtool:
diff --git a/src/Makefile.in b/src/Makefile.in
index a154aff8..b1c1450d 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -152,10 +152,10 @@ all: all-am
.SUFFIXES:
.SUFFIXES: .c .lo .o .obj
-$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu src/Makefile
-Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
libLTLIBRARIES_INSTALL = $(INSTALL)
install-libLTLIBRARIES: $(lib_LTLIBRARIES)
diff --git a/src/compress.c b/src/compress.c
index 78fcf42a..a176b8e2 100644
--- a/src/compress.c
+++ b/src/compress.c
@@ -50,7 +50,7 @@
#endif
#ifndef lint
-FILE_RCSID("@(#)$Id: compress.c,v 1.40 2004/12/20 19:48:59 christos Exp $")
+FILE_RCSID("@(#)$Id: compress.c,v 1.41 2005/01/07 19:17:26 christos Exp $")
#endif
@@ -77,15 +77,16 @@ private int ncompr = sizeof(compr) / sizeof(compr[0]);
private ssize_t swrite(int, const void *, size_t);
private ssize_t sread(int, void *, size_t);
-private size_t uncompressbuf(struct magic_set *, size_t, const unsigned char *,
- unsigned char **, size_t);
+private size_t uncompressbuf(struct magic_set *, int, size_t,
+ const unsigned char *, unsigned char **, size_t);
#ifdef HAVE_LIBZ
private size_t uncompressgzipped(struct magic_set *, const unsigned char *,
unsigned char **, size_t);
#endif
protected int
-file_zmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes)
+file_zmagic(struct magic_set *ms, int fd, const unsigned char *buf,
+ size_t nbytes)
{
unsigned char *newbuf = NULL;
size_t i, nsz;
@@ -98,14 +99,15 @@ file_zmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes)
if (nbytes < compr[i].maglen)
continue;
if (memcmp(buf, compr[i].magic, compr[i].maglen) == 0 &&
- (nsz = uncompressbuf(ms, i, buf, &newbuf, nbytes)) != 0) {
+ (nsz = uncompressbuf(ms, fd, i, buf, &newbuf,
+ nbytes)) != 0) {
ms->flags &= ~MAGIC_COMPRESS;
rv = -1;
- if (file_buffer(ms, newbuf, nsz) == -1)
+ if (file_buffer(ms, -1, newbuf, nsz) == -1)
goto error;
if (file_printf(ms, " (") == -1)
goto error;
- if (file_buffer(ms, buf, nbytes) == -1)
+ if (file_buffer(ms, -1, buf, nbytes) == -1)
goto error;
if (file_printf(ms, ")") == -1)
goto error;
@@ -308,8 +310,8 @@ uncompressgzipped(struct magic_set *ms, const unsigned char *old,
#endif
private size_t
-uncompressbuf(struct magic_set *ms, size_t method, const unsigned char *old,
- unsigned char **newch, size_t n)
+uncompressbuf(struct magic_set *ms, int fd, size_t method,
+ const unsigned char *old, unsigned char **newch, size_t n)
{
int fdin[2], fdout[2];
int r;
@@ -321,26 +323,37 @@ uncompressbuf(struct magic_set *ms, size_t method, const unsigned char *old,
(void)fflush(stdout);
(void)fflush(stderr);
- if (pipe(fdin) == -1 || pipe(fdout) == -1) {
+ if ((fd != -1 && pipe(fdin) == -1) || pipe(fdout) == -1) {
file_error(ms, errno, "cannot create pipe");
return 0;
}
switch (fork()) {
case 0: /* child */
(void) close(0);
- (void) dup(fdin[0]);
- (void) close(fdin[0]);
- (void) close(fdin[1]);
+ if (fd != -1) {
+ (void) dup(fd);
+ (void) lseek(0, (off_t)0, SEEK_SET);
+ } else {
+ (void) dup(fdin[0]);
+ (void) close(fdin[0]);
+ (void) close(fdin[1]);
+ }
(void) close(1);
(void) dup(fdout[1]);
(void) close(fdout[0]);
(void) close(fdout[1]);
+#ifndef DEBUG
if (compr[method].silent)
- (void) close(2);
+ (void)close(2);
+#endif
execvp(compr[method].argv[0],
(char *const *)compr[method].argv);
+#ifdef DEBUG
+ (void)fprintf(stderr, "exec `%s' failed (%s)\n",
+ compr[method].argv[0], strerror(errno));
+#endif
exit(1);
/*NOTREACHED*/
case -1:
@@ -348,31 +361,55 @@ uncompressbuf(struct magic_set *ms, size_t method, const unsigned char *old,
return 0;
default: /* parent */
- (void) close(fdin[0]);
(void) close(fdout[1]);
- /* fork again, to avoid blocking because both pipes filled */
- switch (fork()) {
- case 0: /* child */
- (void)close(fdout[0]);
- if (swrite(fdin[1], old, n) != n)
+ if (fd == -1) {
+ (void) close(fdin[0]);
+ /*
+ * fork again, to avoid blocking because both
+ * pipes filled
+ */
+ switch (fork()) {
+ case 0: /* child */
+ (void)close(fdout[0]);
+ if (swrite(fdin[1], old, n) != n) {
+#ifdef DEBUG
+ (void)fprintf(stderr,
+ "Write failed (%s)\n",
+ strerror(errno));
+#endif
+ exit(1);
+ }
+ exit(0);
+ /*NOTREACHED*/
+
+ case -1:
+#ifdef DEBUG
+ (void)fprintf(stderr, "Fork failed (%s)\n",
+ strerror(errno));
+#endif
exit(1);
- exit(0);
- /*NOTREACHED*/
+ /*NOTREACHED*/
- case -1:
- exit(1);
- /*NOTREACHED*/
-
- default: /* parent */
- break;
+ default: /* parent */
+ break;
+ }
+ (void) close(fdin[1]);
+ fdin[1] = -1;
}
- (void) close(fdin[1]);
- fdin[1] = -1;
+
if ((*newch = (unsigned char *) malloc(HOWMANY + 1)) == NULL) {
+#ifdef DEBUG
+ (void)fprintf(stderr, "Malloc failed (%s)\n",
+ strerror(errno));
+#endif
n = 0;
goto err;
}
if ((r = sread(fdout[0], *newch, HOWMANY)) <= 0) {
+#ifdef DEBUG
+ (void)fprintf(stderr, "Read failed (%s)\n",
+ strerror(errno));
+#endif
free(*newch);
n = 0;
newch[0] = '\0';
diff --git a/src/file.h b/src/file.h
index f29bba01..1fa77586 100644
--- a/src/file.h
+++ b/src/file.h
@@ -27,7 +27,7 @@
*/
/*
* file.h - definitions for file(1) program
- * @(#)$Id: file.h,v 1.64 2004/11/20 23:50:12 christos Exp $
+ * @(#)$Id: file.h,v 1.65 2005/01/07 19:17:26 christos Exp $
*/
#ifndef __file_h__
@@ -241,13 +241,13 @@ struct magic_set {
struct stat;
protected char *file_fmttime(uint32_t, int);
-protected int file_buffer(struct magic_set *, const void *, size_t);
+protected int file_buffer(struct magic_set *, int, const void *, size_t);
protected int file_fsmagic(struct magic_set *, const char *, struct stat *);
protected int file_pipe2file(struct magic_set *, int, const void *, size_t);
protected int file_printf(struct magic_set *, const char *, ...);
protected int file_reset(struct magic_set *);
protected int file_tryelf(struct magic_set *, int, const unsigned char *, size_t);
-protected int file_zmagic(struct magic_set *, const unsigned char *, size_t);
+protected int file_zmagic(struct magic_set *, int, const unsigned char *, size_t);
protected int file_ascmagic(struct magic_set *, const unsigned char *, size_t);
protected int file_is_tar(struct magic_set *, const unsigned char *, size_t);
protected int file_softmagic(struct magic_set *, const unsigned char *, size_t);
diff --git a/src/funcs.c b/src/funcs.c
index bd77f13c..a2ceff7f 100644
--- a/src/funcs.c
+++ b/src/funcs.c
@@ -32,7 +32,7 @@
#include <ctype.h>
#ifndef lint
-FILE_RCSID("@(#)$Id: funcs.c,v 1.13 2004/09/11 19:15:57 christos Exp $")
+FILE_RCSID("@(#)$Id: funcs.c,v 1.14 2005/01/07 19:17:27 christos Exp $")
#endif /* lint */
/*
* Like printf, only we print to a buffer and advance it.
@@ -110,11 +110,11 @@ file_badread(struct magic_set *ms)
#ifndef COMPILE_ONLY
protected int
-file_buffer(struct magic_set *ms, const void *buf, size_t nb)
+file_buffer(struct magic_set *ms, int fd, const void *buf, size_t nb)
{
int m;
/* try compression stuff */
- if ((m = file_zmagic(ms, buf, nb)) == 0) {
+ if ((m = file_zmagic(ms, fd, buf, nb)) == 0) {
/* Check if we have a tar file */
if ((m = file_is_tar(ms, buf, nb)) == 0) {
/* try tests in /etc/magic (or surrogate magic file) */
diff --git a/src/magic.c b/src/magic.c
index 4516ba85..872b62d0 100644
--- a/src/magic.c
+++ b/src/magic.c
@@ -63,7 +63,7 @@
#include "patchlevel.h"
#ifndef lint
-FILE_RCSID("@(#)$Id: magic.c,v 1.24 2004/09/27 15:28:37 christos Exp $")
+FILE_RCSID("@(#)$Id: magic.c,v 1.25 2005/01/07 19:17:27 christos Exp $")
#endif /* lint */
#ifdef __EMX__
@@ -277,7 +277,7 @@ magic_file(struct magic_set *ms, const char *inname)
goto gotit;
}
#endif
- if (file_buffer(ms, buf, (size_t)nbytes) == -1)
+ if (file_buffer(ms, fd, buf, (size_t)nbytes) == -1)
goto done;
#ifdef BUILTIN_ELF
if (nbytes > 5) {
@@ -311,7 +311,7 @@ magic_buffer(struct magic_set *ms, const void *buf, size_t nb)
* The main work is done here!
* We have the file name and/or the data buffer to be identified.
*/
- if (file_buffer(ms, buf, nb) == -1) {
+ if (file_buffer(ms, -1, buf, nb) == -1) {
return NULL;
}
return file_getbuffer(ms);