updated libmagic.patch in 5.5

This commit is contained in:
Anatol Belski 2015-01-04 17:05:42 +01:00
parent c772261319
commit 4ed261870f

View File

@ -1,6 +1,6 @@
diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
--- libmagic.orig/apprentice.c Thu Mar 21 18:45:14 2013
+++ libmagic/apprentice.c Mon Nov 17 15:42:41 2014
+++ libmagic/apprentice.c Sun Jan 4 17:02:29 2015
@@ -29,6 +29,8 @@
* apprentice - make one pass through /etc/magic, learning its secrets.
*/
@ -842,7 +842,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
}
diff -u libmagic.orig/ascmagic.c libmagic/ascmagic.c
--- libmagic.orig/ascmagic.c Wed Oct 31 18:03:01 2012
+++ libmagic/ascmagic.c Mon Nov 17 15:42:41 2014
+++ libmagic/ascmagic.c Sun Jan 4 17:02:29 2015
@@ -139,7 +139,7 @@
/* malloc size is a conservative overestimate; could be
improved, or at least realloced after conversion. */
@ -881,7 +881,7 @@ diff -u libmagic.orig/ascmagic.c libmagic/ascmagic.c
}
diff -u libmagic.orig/cdf.c libmagic/cdf.c
--- libmagic.orig/cdf.c Thu Mar 21 18:45:14 2013
+++ libmagic/cdf.c Mon Nov 17 15:42:41 2014
+++ libmagic/cdf.c Sun Jan 4 17:02:29 2015
@@ -43,7 +43,17 @@
#include <err.h>
#endif
@ -1070,7 +1070,7 @@ diff -u libmagic.orig/cdf.c libmagic/cdf.c
} else {
diff -u libmagic.orig/cdf.h libmagic/cdf.h
--- libmagic.orig/cdf.h Wed Oct 31 18:03:01 2012
+++ libmagic/cdf.h Mon Nov 17 15:42:41 2014
+++ libmagic/cdf.h Sun Jan 4 17:02:29 2015
@@ -35,10 +35,12 @@
#ifndef _H_CDF_
#define _H_CDF_
@ -1173,7 +1173,7 @@ diff -u libmagic.orig/cdf_time.c libmagic/cdf_time.c
static const char *ref = "Sat Apr 23 01:30:00 1977";
diff -u libmagic.orig/compress.c libmagic/compress.c
--- libmagic.orig/compress.c Sun Jan 6 21:35:43 2013
+++ libmagic/compress.c Mon Nov 17 15:42:41 2014
+++ libmagic/compress.c Sun Jan 4 17:02:29 2015
@@ -32,6 +32,7 @@
* uncompress(method, old, n, newch) - uncompress old into new,
* using method, return sizeof new
@ -1336,7 +1336,7 @@ diff -u libmagic.orig/compress.c libmagic/compress.c
+#endif /* if PHP_FILEINFO_UNCOMPRESS */
diff -u libmagic.orig/file.h libmagic/file.h
--- libmagic.orig/file.h Mon Feb 18 16:40:59 2013
+++ libmagic/file.h Mon Nov 17 15:42:41 2014
+++ libmagic/file.h Sun Jan 4 17:02:29 2015
@@ -33,11 +33,9 @@
#ifndef __file_h__
#define __file_h__
@ -1423,7 +1423,7 @@ diff -u libmagic.orig/file.h libmagic/file.h
void *map; /* internal resources used by entry */
struct mlist *next, *prev;
};
@@ -411,21 +413,18 @@
@@ -411,21 +413,16 @@
protected const char *file_fmttime(uint64_t, int, char *);
protected struct magic_set *file_ms_alloc(int);
protected void file_ms_free(struct magic_set *);
@ -1440,8 +1440,8 @@ diff -u libmagic.orig/file.h libmagic/file.h
- __attribute__((__format__(__printf__, 2, 3)));
+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_tryelf(struct magic_set *, int, const unsigned char *,
- size_t);
protected int file_trycdf(struct magic_set *, int, const unsigned char *,
size_t);
-#if HAVE_FORK
@ -1449,7 +1449,7 @@ diff -u libmagic.orig/file.h libmagic/file.h
protected int file_zmagic(struct magic_set *, int, const char *,
const unsigned char *, size_t);
#endif
@@ -438,21 +437,18 @@
@@ -438,21 +435,18 @@
unichar **, size_t *, const char **, const char **, const char **);
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,
@ -1476,7 +1476,7 @@ diff -u libmagic.orig/file.h libmagic/file.h
protected void file_showstr(FILE *, const char *, size_t);
protected size_t file_mbswidth(const char *);
protected const char *file_getbuffer(struct magic_set *);
@@ -462,16 +458,14 @@
@@ -462,16 +456,14 @@
size_t *);
protected size_t file_pstring_length_size(const struct magic *);
protected size_t file_pstring_get_length(const struct magic *, const char *);
@ -1494,7 +1494,7 @@ diff -u libmagic.orig/file.h libmagic/file.h
#ifndef HAVE_STRERROR
extern int sys_nerr;
@@ -484,32 +478,16 @@
@@ -484,32 +476,16 @@
#define strtoul(a, b, c) strtol(a, b, c)
#endif
@ -1529,7 +1529,7 @@ diff -u libmagic.orig/file.h libmagic/file.h
#if defined(HAVE_MMAP) && defined(HAVE_SYS_MMAN_H) && !defined(QUICK)
#define QUICK
@@ -531,6 +509,14 @@
@@ -531,6 +507,14 @@
#endif
#else
#define FILE_RCSID(id)
@ -1546,7 +1546,7 @@ diff -u libmagic.orig/file.h libmagic/file.h
#endif /* __file_h__ */
diff -u libmagic.orig/fsmagic.c libmagic/fsmagic.c
--- libmagic.orig/fsmagic.c Thu Mar 21 18:45:14 2013
+++ libmagic/fsmagic.c Mon Nov 17 15:42:41 2014
+++ libmagic/fsmagic.c Sun Jan 4 17:02:29 2015
@@ -59,27 +59,21 @@
# define minor(dev) ((dev) & 0xff)
#endif
@ -1913,7 +1913,7 @@ diff -u libmagic.orig/fsmagic.c libmagic/fsmagic.c
}
diff -u libmagic.orig/funcs.c libmagic/funcs.c
--- libmagic.orig/funcs.c Wed Oct 31 18:03:01 2012
+++ libmagic/funcs.c Mon Nov 17 15:42:41 2014
+++ libmagic/funcs.c Sun Jan 4 17:02:29 2015
@@ -41,52 +41,42 @@
#if defined(HAVE_WCTYPE_H)
#include <wctype.h>
@ -2207,7 +2207,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
+
diff -u libmagic.orig/magic.c libmagic/magic.c
--- libmagic.orig/magic.c Fri Jan 11 17:43:09 2013
+++ libmagic/magic.c Mon Nov 17 15:42:41 2014
+++ libmagic/magic.c Sun Jan 4 17:02:29 2015
@@ -25,11 +25,6 @@
* SUCH DAMAGE.
*/
@ -2551,7 +2551,7 @@ diff -u libmagic.orig/magic.c libmagic/magic.c
magic_error(struct magic_set *ms)
diff -u libmagic.orig/magic.h libmagic/magic.h
--- libmagic.orig/magic.h Thu Mar 21 18:52:42 2013
+++ libmagic/magic.h Mon Nov 17 15:42:41 2014
+++ libmagic/magic.h Sun Jan 4 17:02:29 2015
@@ -87,6 +87,7 @@
const char *magic_getpath(const char *, int);
@ -2570,7 +2570,7 @@ diff -u libmagic.orig/magic.h libmagic/magic.h
diff -u libmagic.orig/print.c libmagic/print.c
--- libmagic.orig/print.c Thu Mar 21 18:45:14 2013
+++ libmagic/print.c Tue Dec 30 20:08:56 2014
+++ libmagic/print.c Sun Jan 4 17:04:32 2015
@@ -28,13 +28,17 @@
/*
* print.c - debugging printout routines
@ -2804,7 +2804,7 @@ diff -u libmagic.orig/print.c libmagic/print.c
}
diff -u libmagic.orig/readcdf.c libmagic/readcdf.c
--- libmagic.orig/readcdf.c Wed Oct 31 18:03:01 2012
+++ libmagic/readcdf.c Mon Nov 17 15:42:41 2014
+++ libmagic/readcdf.c Sun Jan 4 17:02:29 2015
@@ -30,7 +30,11 @@
#endif
@ -2878,296 +2878,9 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c
} else {
if (file_printf(ms, "application/CDFV2-corrupt") == -1)
return -1;
diff -u libmagic.orig/readelf.c libmagic/readelf.c
--- libmagic.orig/readelf.c Thu Mar 21 18:45:14 2013
+++ libmagic/readelf.c Mon Nov 17 15:42:41 2014
@@ -48,8 +48,8 @@
private int dophn_exec(struct magic_set *, int, int, int, off_t, int, size_t,
off_t, int *, int);
private int doshn(struct magic_set *, int, int, int, off_t, int, size_t,
- off_t, int *, int, int);
-private size_t donote(struct magic_set *, void *, size_t, size_t, int,
+ off_t, int *, int);
+private size_t donote(struct magic_set *, unsigned char *, size_t, size_t, int,
int, size_t, int *);
#define ELF_ALIGN(a) ((((a) + align - 1) / align) * align)
@@ -127,11 +127,17 @@
#define elf_getu16(swap, value) getu16(swap, value)
#define elf_getu32(swap, value) getu32(swap, value)
-#define elf_getu64(swap, value) getu64(swap, value)
+#ifdef USE_ARRAY_FOR_64BIT_TYPES
+# define elf_getu64(swap, array) \
+ ((swap ? ((uint64_t)elf_getu32(swap, array[0])) << 32 : elf_getu32(swap, array[0])) + \
+ (swap ? elf_getu32(swap, array[1]) : ((uint64_t)elf_getu32(swap, array[1]) << 32)))
+#else
+# define elf_getu64(swap, value) getu64(swap, value)
+#endif
#define xsh_addr (clazz == ELFCLASS32 \
- ? (void *)&sh32 \
- : (void *)&sh64)
+ ? (void *) &sh32 \
+ : (void *) &sh64)
#define xsh_sizeof (clazz == ELFCLASS32 \
? sizeof(sh32) \
: sizeof(sh64))
@@ -168,8 +174,8 @@
? elf_getu32(swap, ph32.p_filesz) \
: elf_getu64(swap, ph64.p_filesz)))
#define xnh_addr (clazz == ELFCLASS32 \
- ? (void *)&nh32 \
- : (void *)&nh64)
+ ? (void *) &nh32 \
+ : (void *) &nh64)
#define xph_memsz (size_t)((clazz == ELFCLASS32 \
? elf_getu32(swap, ph32.p_memsz) \
: elf_getu64(swap, ph64.p_memsz)))
@@ -189,8 +195,8 @@
? prpsoffsets32[i] \
: prpsoffsets64[i])
#define xcap_addr (clazz == ELFCLASS32 \
- ? (void *)&cap32 \
- : (void *)&cap64)
+ ? (void *) &cap32 \
+ : (void *) &cap64)
#define xcap_sizeof (clazz == ELFCLASS32 \
? sizeof cap32 \
: sizeof cap64)
@@ -292,7 +298,7 @@
{
Elf32_Phdr ph32;
Elf64_Phdr ph64;
- size_t offset, len;
+ size_t offset;
unsigned char nbuf[BUFSIZ];
ssize_t bufsize;
@@ -306,7 +312,11 @@
* Loop through all the program headers.
*/
for ( ; num; num--) {
- if (pread(fd, xph_addr, xph_sizeof, off) == -1) {
+ if (FINFO_LSEEK_FUNC(fd, off, SEEK_SET) == (off_t)-1) {
+ file_badseek(ms);
+ return -1;
+ }
+ if (FINFO_READ_FUNC(fd, xph_addr, xph_sizeof) == -1) {
file_badread(ms);
return -1;
}
@@ -324,8 +334,13 @@
* This is a PT_NOTE section; loop through all the notes
* in the section.
*/
- len = xph_filesz < sizeof(nbuf) ? xph_filesz : sizeof(nbuf);
- if ((bufsize = pread(fd, nbuf, len, xph_offset)) == -1) {
+ if (FINFO_LSEEK_FUNC(fd, xph_offset, SEEK_SET) == (off_t)-1) {
+ file_badseek(ms);
+ return -1;
+ }
+ bufsize = FINFO_READ_FUNC(fd, nbuf,
+ ((xph_filesz < sizeof(nbuf)) ? xph_filesz : sizeof(nbuf)));
+ if (bufsize == -1) {
file_badread(ms);
return -1;
}
@@ -357,6 +372,13 @@
uint32_t namesz, descsz;
unsigned char *nbuf = CAST(unsigned char *, vbuf);
+ if (xnh_sizeof + offset > size) {
+ /*
+ * We're out of note headers.
+ */
+ return xnh_sizeof + offset;
+ }
+
(void)memcpy(xnh_addr, &nbuf[offset], xnh_sizeof);
offset += xnh_sizeof;
@@ -852,24 +874,12 @@
return 0;
}
- /* Read offset of name section to be able to read section names later */
- if (pread(fd, xsh_addr, xsh_sizeof, off + size * strtab) == -1) {
- file_badread(ms);
- return -1;
- }
- name_off = xsh_offset;
-
for ( ; num; num--) {
- /* Read the name of this section. */
- if (pread(fd, name, sizeof(name), name_off + xsh_name) == -1) {
- file_badread(ms);
+ if (FINFO_LSEEK_FUNC(fd, off, SEEK_SET) == (off_t)-1) {
+ file_badseek(ms);
return -1;
}
- name[sizeof(name) - 1] = '\0';
- if (strcmp(name, ".debug_info") == 0)
- stripped = 0;
-
- if (pread(fd, xsh_addr, xsh_sizeof, off) == -1) {
+ if (FINFO_READ_FUNC(fd, xsh_addr, xsh_sizeof) == -1) {
file_badread(ms);
return -1;
}
@@ -894,14 +904,17 @@
/* Things we can determine when we seek */
switch (xsh_type) {
case SHT_NOTE:
- if ((nbuf = malloc(xsh_size)) == NULL) {
- file_error(ms, errno, "Cannot allocate memory"
- " for note");
+ nbuf = emalloc((size_t)xsh_size);
+ if ((noff = FINFO_LSEEK_FUNC(fd, (off_t)xsh_offset, SEEK_SET)) ==
+ (off_t)-1) {
+ file_badread(ms);
+ efree(nbuf);
return -1;
}
- if (pread(fd, nbuf, xsh_size, xsh_offset) == -1) {
+ if (FINFO_READ_FUNC(fd, nbuf, (size_t)xsh_size) !=
+ (ssize_t)xsh_size) {
+ efree(nbuf);
file_badread(ms);
- free(nbuf);
return -1;
}
@@ -910,25 +923,16 @@
if (noff >= (off_t)xsh_size)
break;
noff = donote(ms, nbuf, (size_t)noff,
- xsh_size, clazz, swap, 4, flags);
+ (size_t)xsh_size, clazz, swap, 4,
+ flags);
if (noff == 0)
break;
}
- free(nbuf);
+ efree(nbuf);
break;
case SHT_SUNW_cap:
- switch (mach) {
- case EM_SPARC:
- case EM_SPARCV9:
- case EM_IA_64:
- case EM_386:
- case EM_AMD64:
- break;
- default:
- goto skip;
- }
-
- if (lseek(fd, xsh_offset, SEEK_SET) == (off_t)-1) {
+ if (FINFO_LSEEK_FUNC(fd, (off_t)xsh_offset, SEEK_SET) ==
+ (off_t)-1) {
file_badseek(ms);
return -1;
}
@@ -940,7 +944,7 @@
MAX(sizeof cap32, sizeof cap64)];
if ((coff += xcap_sizeof) > (off_t)xsh_size)
break;
- if (read(fd, cbuf, (size_t)xcap_sizeof) !=
+ if (FINFO_READ_FUNC(fd, cbuf, (size_t)xcap_sizeof) !=
(ssize_t)xcap_sizeof) {
file_badread(ms);
return -1;
@@ -966,13 +970,12 @@
break;
}
}
- /*FALLTHROUGH*/
- skip:
+ break;
+
default:
break;
}
}
-
if (file_printf(ms, ", %sstripped", stripped ? "" : "not ") == -1)
return -1;
if (cap_hw1) {
@@ -1051,7 +1054,7 @@
const char *shared_libraries = "";
unsigned char nbuf[BUFSIZ];
ssize_t bufsize;
- size_t offset, align, len;
+ size_t offset, align;
if (size != xph_sizeof) {
if (file_printf(ms, ", corrupted program header size") == -1)
@@ -1060,8 +1063,13 @@
}
for ( ; num; num--) {
- if (pread(fd, xph_addr, xph_sizeof, off) == -1) {
- file_badread(ms);
+ if (FINFO_LSEEK_FUNC(fd, off, SEEK_SET) == (off_t)-1) {
+ file_badseek(ms);
+ return -1;
+ }
+
+ if (FINFO_READ_FUNC(fd, xph_addr, xph_sizeof) == -1) {
+ file_badread(ms);
return -1;
}
@@ -1099,9 +1107,12 @@
* This is a PT_NOTE section; loop through all the notes
* in the section.
*/
- len = xph_filesz < sizeof(nbuf) ? xph_filesz
- : sizeof(nbuf);
- bufsize = pread(fd, nbuf, len, xph_offset);
+ if (FINFO_LSEEK_FUNC(fd, xph_offset, SEEK_SET) == (off_t)-1) {
+ file_badseek(ms);
+ return -1;
+ }
+ bufsize = FINFO_READ_FUNC(fd, nbuf, ((xph_filesz < sizeof(nbuf)) ?
+ xph_filesz : sizeof(nbuf)));
if (bufsize == -1) {
file_badread(ms);
return -1;
@@ -1162,7 +1173,7 @@
/*
* If we cannot seek, it must be a pipe, socket or fifo.
*/
- if((lseek(fd, (off_t)0, SEEK_SET) == (off_t)-1) && (errno == ESPIPE))
+ if((FINFO_LSEEK_FUNC(fd, (off_t)0, SEEK_SET) == (off_t)-1) && (errno == ESPIPE))
fd = file_pipe2file(ms, fd, buf, nbytes);
if (fstat(fd, &st) == -1) {
diff -u libmagic.orig/readelf.h libmagic/readelf.h
--- libmagic.orig/readelf.h Thu Mar 21 18:45:14 2013
+++ libmagic/readelf.h Mon Nov 17 15:42:41 2014
@@ -44,9 +44,17 @@
typedef uint32_t Elf32_Word;
typedef uint8_t Elf32_Char;
+#if SIZEOF_LONG_LONG != 8
+#define USE_ARRAY_FOR_64BIT_TYPES
+typedef uint32_t Elf64_Addr[2];
+typedef uint32_t Elf64_Off[2];
+typedef uint32_t Elf64_Xword[2];
+#else
+#undef USE_ARRAY_FOR_64BIT_TYPES
typedef uint64_t Elf64_Addr;
typedef uint64_t Elf64_Off;
typedef uint64_t Elf64_Xword;
+#endif
typedef uint16_t Elf64_Half;
typedef uint32_t Elf64_Word;
typedef uint8_t Elf64_Char;
diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
--- libmagic.orig/softmagic.c Thu Mar 21 18:45:14 2013
+++ libmagic/softmagic.c Mon Nov 17 15:42:41 2014
+++ libmagic/softmagic.c Sun Jan 4 17:02:29 2015
@@ -41,6 +41,11 @@
#include <stdlib.h>
#include <time.h>
@ -3326,7 +3039,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
break; \
} \
@@ -896,10 +881,18 @@
@@ -896,10 +881,21 @@
return 1;
}
case FILE_PSTRING: {
@ -3336,19 +3049,22 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
size_t len = file_pstring_get_length(m, ptr1);
- if (len >= sizeof(p->s))
- len = sizeof(p->s) - 1;
+ if (len >= sizeof(p->s)) {
+ sz = sizeof(p->s) - sz; /* maximum length of string */
+ if (len >= sz) {
+ /*
+ * The size of the pascal string length (sz)
+ * is 1, 2, or 4. We need at least 1 byte for NUL
+ * termination, but we've already truncated the
+ * string by p->s, so we need to deduct sz.
+ * Because we can use one of the bytes of the length
+ * after we shifted as NUL termination.
+ */
+ len = sizeof(p->s) - sz;
+ len = sz;
+ }
while (len--)
*ptr1++ = *ptr2++;
*ptr1 = '\0';
@@ -1010,7 +1003,7 @@
@@ -1010,7 +1006,7 @@
private int
mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir,
@ -3357,7 +3073,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
{
/*
* Note: FILE_SEARCH and FILE_REGEX do not actually copy
@@ -1030,15 +1023,24 @@
@@ -1030,15 +1026,24 @@
const char *last; /* end of search region */
const char *buf; /* start of search region */
const char *end;
@ -3384,7 +3100,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
/* mget() guarantees buf <= last */
for (lines = linecnt, b = buf; lines && b < end &&
((b = CAST(const char *,
@@ -1051,7 +1053,7 @@
@@ -1051,7 +1056,7 @@
b++;
}
if (lines)
@ -3393,7 +3109,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
ms->search.s = buf;
ms->search.s_len = last - buf;
@@ -1125,7 +1127,6 @@
@@ -1125,7 +1130,6 @@
int *need_separator, int *returnval)
{
uint32_t soffset, offset = ms->offset;
@ -3401,7 +3117,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
int rv, oneed_separator;
char *sbuf, *rbuf;
union VALUETYPE *p = &ms->ms_value;
@@ -1137,17 +1138,13 @@
@@ -1137,17 +1141,13 @@
}
if (mcopy(ms, p, m->type, m->flag & INDIR, s, (uint32_t)(offset + o),
@ -3421,7 +3137,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
}
if (m->flag & INDIR) {
@@ -1191,7 +1188,7 @@
@@ -1191,7 +1191,7 @@
}
switch (cvt_flip(m->in_type, flip)) {
case FILE_BYTE:
@ -3430,7 +3146,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
return 0;
if (off) {
switch (m->in_op & FILE_OPS_MASK) {
@@ -1226,7 +1223,7 @@
@@ -1226,7 +1226,7 @@
offset = ~offset;
break;
case FILE_BESHORT:
@ -3439,7 +3155,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
return 0;
if (off) {
switch (m->in_op & FILE_OPS_MASK) {
@@ -1278,7 +1275,7 @@
@@ -1278,7 +1278,7 @@
offset = ~offset;
break;
case FILE_LESHORT:
@ -3448,7 +3164,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
return 0;
if (off) {
switch (m->in_op & FILE_OPS_MASK) {
@@ -1330,7 +1327,7 @@
@@ -1330,7 +1330,7 @@
offset = ~offset;
break;
case FILE_SHORT:
@ -3457,7 +3173,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
return 0;
if (off) {
switch (m->in_op & FILE_OPS_MASK) {
@@ -1367,7 +1364,7 @@
@@ -1367,7 +1367,7 @@
break;
case FILE_BELONG:
case FILE_BEID3:
@ -3466,7 +3182,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
return 0;
if (off) {
switch (m->in_op & FILE_OPS_MASK) {
@@ -1438,7 +1435,7 @@
@@ -1438,7 +1438,7 @@
break;
case FILE_LELONG:
case FILE_LEID3:
@ -3475,7 +3191,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
return 0;
if (off) {
switch (m->in_op & FILE_OPS_MASK) {
@@ -1508,7 +1505,7 @@
@@ -1508,7 +1508,7 @@
offset = ~offset;
break;
case FILE_MELONG:
@ -3484,7 +3200,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
return 0;
if (off) {
switch (m->in_op & FILE_OPS_MASK) {
@@ -1578,7 +1575,7 @@
@@ -1578,7 +1578,7 @@
offset = ~offset;
break;
case FILE_LONG:
@ -3493,7 +3209,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
return 0;
if (off) {
switch (m->in_op & FILE_OPS_MASK) {
@@ -1637,30 +1634,27 @@
@@ -1637,30 +1637,27 @@
if ((ms->flags & MAGIC_DEBUG) != 0)
fprintf(stderr, "indirect +offs=%u\n", offset);
}
@ -3527,7 +3243,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
return 0;
break;
@@ -1679,38 +1673,40 @@
@@ -1679,38 +1676,40 @@
case FILE_FLOAT:
case FILE_BEFLOAT:
case FILE_LEFLOAT:
@ -3574,7 +3290,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
if ((ms->flags & MAGIC_DEBUG) != 0)
fprintf(stderr, "indirect @offs=%u[%d]\n", offset, rv);
rbuf = ms->o.buf;
@@ -1718,16 +1714,26 @@
@@ -1718,16 +1717,26 @@
ms->offset = soffset;
if (rv == 1) {
if ((ms->flags & (MAGIC_MIME|MAGIC_APPLE)) == 0 &&
@ -3605,7 +3321,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
return 0;
sbuf = m->value.s;
if (*sbuf == '^') {
@@ -1837,6 +1843,42 @@
@@ -1837,6 +1846,42 @@
return file_strncmp(a, b, len, flags);
}
@ -3648,7 +3364,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
private int
magiccheck(struct magic_set *ms, struct magic *m)
{
@@ -1996,69 +2038,157 @@
@@ -1996,69 +2041,157 @@
break;
}
case FILE_REGEX: {