Skip to content

Commit

Permalink
Upgrade bundled libmagic to 5.31
Browse files Browse the repository at this point in the history
  • Loading branch information
weltling committed Oct 11, 2017
1 parent 1f150fc commit 08d8623
Show file tree
Hide file tree
Showing 20 changed files with 59,236 additions and 50,129 deletions.
101,315 changes: 54,495 additions & 46,820 deletions ext/fileinfo/data_file.c

Large diffs are not rendered by default.

410 changes: 219 additions & 191 deletions ext/fileinfo/libmagic.patch

Large diffs are not rendered by default.

27 changes: 21 additions & 6 deletions ext/fileinfo/libmagic/apprentice.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include "file.h"

#ifndef lint
FILE_RCSID("@(#)$File: apprentice.c,v 1.255 2016/10/24 18:02:17 christos Exp $")
FILE_RCSID("@(#)$File: apprentice.c,v 1.260 2017/04/28 16:27:58 christos Exp $")
#endif /* lint */

#include "magic.h"
Expand Down Expand Up @@ -2235,7 +2235,7 @@ parse_ext(struct magic_set *ms, struct magic_entry *me, const char *line)

return parse_extra(ms, me, line,
CAST(off_t, offsetof(struct magic, ext)),
sizeof(m->ext), "EXTENSION", ",!+-/", 0);
sizeof(m->ext), "EXTENSION", ",!+-/@", 0);
}

/*
Expand Down Expand Up @@ -2296,6 +2296,8 @@ check_format_type(const char *ptr, int type, const char **estr)
ptr++;
if (*ptr == '.')
ptr++;
if (*ptr == '#')
ptr++;
#define CHECKLEN() do { \
for (len = cnt = 0; isdigit((unsigned char)*ptr); ptr++, cnt++) \
len = len * 10 + (*ptr - '0'); \
Expand Down Expand Up @@ -3289,22 +3291,35 @@ file_pstring_get_length(const struct magic *m, const char *ss)
{
size_t len = 0;
const unsigned char *s = (const unsigned char *)ss;
unsigned int s3, s2, s1, s0;

switch (m->str_flags & PSTRING_LEN) {
case PSTRING_1_LE:
len = *s;
break;
case PSTRING_2_LE:
len = (s[1] << 8) | s[0];
s0 = s[0];
s1 = s[1];
len = (s1 << 8) | s0;
break;
case PSTRING_2_BE:
len = (s[0] << 8) | s[1];
s0 = s[0];
s1 = s[1];
len = (s0 << 8) | s1;
break;
case PSTRING_4_LE:
len = (s[3] << 24) | (s[2] << 16) | (s[1] << 8) | s[0];
s0 = s[0];
s1 = s[1];
s2 = s[2];
s3 = s[3];
len = (s3 << 24) | (s2 << 16) | (s1 << 8) | s0;
break;
case PSTRING_4_BE:
len = (s[0] << 24) | (s[1] << 16) | (s[2] << 8) | s[3];
s0 = s[0];
s1 = s[1];
s2 = s[2];
s3 = s[3];
len = (s0 << 24) | (s1 << 16) | (s2 << 8) | s3;
break;
default:
abort(); /* Impossible */
Expand Down

0 comments on commit 08d8623

Please sign in to comment.