Skip to content

Commit 08d8623

Browse files
committedOct 11, 2017
Upgrade bundled libmagic to 5.31
1 parent 1f150fc commit 08d8623

20 files changed

+59236
-50129
lines changed
 

‎ext/fileinfo/data_file.c

+54,495-46,820
Large diffs are not rendered by default.

‎ext/fileinfo/libmagic.patch

+219-191
Large diffs are not rendered by default.

‎ext/fileinfo/libmagic/apprentice.c

+21-6
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include "file.h"
3535

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

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

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

22412241
/*
@@ -2296,6 +2296,8 @@ check_format_type(const char *ptr, int type, const char **estr)
22962296
ptr++;
22972297
if (*ptr == '.')
22982298
ptr++;
2299+
if (*ptr == '#')
2300+
ptr++;
22992301
#define CHECKLEN() do { \
23002302
for (len = cnt = 0; isdigit((unsigned char)*ptr); ptr++, cnt++) \
23012303
len = len * 10 + (*ptr - '0'); \
@@ -3289,22 +3291,35 @@ file_pstring_get_length(const struct magic *m, const char *ss)
32893291
{
32903292
size_t len = 0;
32913293
const unsigned char *s = (const unsigned char *)ss;
3294+
unsigned int s3, s2, s1, s0;
32923295

32933296
switch (m->str_flags & PSTRING_LEN) {
32943297
case PSTRING_1_LE:
32953298
len = *s;
32963299
break;
32973300
case PSTRING_2_LE:
3298-
len = (s[1] << 8) | s[0];
3301+
s0 = s[0];
3302+
s1 = s[1];
3303+
len = (s1 << 8) | s0;
32993304
break;
33003305
case PSTRING_2_BE:
3301-
len = (s[0] << 8) | s[1];
3306+
s0 = s[0];
3307+
s1 = s[1];
3308+
len = (s0 << 8) | s1;
33023309
break;
33033310
case PSTRING_4_LE:
3304-
len = (s[3] << 24) | (s[2] << 16) | (s[1] << 8) | s[0];
3311+
s0 = s[0];
3312+
s1 = s[1];
3313+
s2 = s[2];
3314+
s3 = s[3];
3315+
len = (s3 << 24) | (s2 << 16) | (s1 << 8) | s0;
33053316
break;
33063317
case PSTRING_4_BE:
3307-
len = (s[0] << 24) | (s[1] << 16) | (s[2] << 8) | s[3];
3318+
s0 = s[0];
3319+
s1 = s[1];
3320+
s2 = s[2];
3321+
s3 = s[3];
3322+
len = (s0 << 24) | (s1 << 16) | (s2 << 8) | s3;
33083323
break;
33093324
default:
33103325
abort(); /* Impossible */

0 commit comments

Comments
 (0)
Failed to load comments.