mirror of
https://github.com/php/php-src.git
synced 2025-08-15 13:38:49 +02:00
Upgrade to file 5.46
This commit is contained in:
parent
d3da2a2884
commit
37dbad8fcd
21 changed files with 11077 additions and 9013 deletions
3
NEWS
3
NEWS
|
@ -41,6 +41,9 @@ PHP NEWS
|
|||
. Added enchant_dict_remove_from_session(). (nielsdos)
|
||||
. Added enchant_dict_remove(). (nielsdos)
|
||||
|
||||
- Fileinfo:
|
||||
. Upgrade to file 5.46. (nielsdos)
|
||||
|
||||
- GD:
|
||||
. Fixed bug #68629 (Transparent artifacts when using imagerotate). (pierre,
|
||||
cmb)
|
||||
|
|
|
@ -247,6 +247,9 @@ PHP 8.5 UPGRADE NOTES
|
|||
9. Other Changes to Extensions
|
||||
========================================
|
||||
|
||||
- Fileinfo:
|
||||
. Upgraded to file 5.46.
|
||||
|
||||
- Readline:
|
||||
. The return types of readline_add_history(), readline_clear_history(), and
|
||||
readline_callback_handler_install() have been changed to true, rather
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
for ($i = ord(' '); $i < 0x7F; ++$i) {
|
||||
$map[chr($i)] = chr($i);
|
||||
}
|
||||
// … Except trigraphs
|
||||
$map["?"] = '\?';
|
||||
// … Except digits following a \0: \012 will be interpreted as octal 012, and not \0 followed by 12.
|
||||
// Then we have to express \0 in a full unambiguous 3-chars octal code.
|
||||
for ($i = ord('0'); $i <= ord('9'); ++$i) {
|
||||
|
|
18429
ext/fileinfo/data_file.c
18429
ext/fileinfo/data_file.c
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
VERSION=5.45
|
||||
VERSION=5.46
|
||||
|
||||
# Go to fileinfo extension directory.
|
||||
cd "$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)" || exit
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -32,7 +32,7 @@
|
|||
#include "file.h"
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$File: apprentice.c,v 1.342 2023/07/17 14:38:35 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: apprentice.c,v 1.355 2024/11/25 22:31:53 christos Exp $")
|
||||
#endif /* lint */
|
||||
|
||||
#include "magic.h"
|
||||
|
@ -109,17 +109,17 @@ struct magic_map {
|
|||
uint32_t nmagic[MAGIC_SETS];
|
||||
};
|
||||
|
||||
int file_formats[FILE_NAMES_SIZE];
|
||||
const size_t file_nformats = FILE_NAMES_SIZE;
|
||||
const char *file_names[FILE_NAMES_SIZE];
|
||||
const size_t file_nnames = FILE_NAMES_SIZE;
|
||||
file_private int file_formats[FILE_NAMES_SIZE];
|
||||
file_private const size_t file_nformats = FILE_NAMES_SIZE;
|
||||
file_protected const char *file_names[FILE_NAMES_SIZE];
|
||||
file_protected const size_t file_nnames = FILE_NAMES_SIZE;
|
||||
|
||||
file_private int getvalue(struct magic_set *ms, struct magic *, const char **, int);
|
||||
file_private int hextoint(int);
|
||||
file_private const char *getstr(struct magic_set *, struct magic *, const char *,
|
||||
int);
|
||||
file_private int parse(struct magic_set *, struct magic_entry *, const char *,
|
||||
size_t, int);
|
||||
const char *, size_t, int);
|
||||
file_private void eatsize(const char **);
|
||||
file_private int apprentice_1(struct magic_set *, const char *, int);
|
||||
file_private ssize_t apprentice_magic_strength_1(const struct magic *);
|
||||
|
@ -342,7 +342,11 @@ get_standard_integer_type(const char *l, const char **t)
|
|||
{
|
||||
int type;
|
||||
|
||||
if (isalpha(CAST(unsigned char, l[1]))) {
|
||||
if (l[0] == '\0')
|
||||
return FILE_INVALID;
|
||||
if (l[1] == '\0')
|
||||
return FILE_INVALID;
|
||||
else if (isalpha(CAST(unsigned char, l[1]))) {
|
||||
switch (l[1]) {
|
||||
case 'C':
|
||||
/* "dC" and "uC" */
|
||||
|
@ -489,7 +493,7 @@ apprentice_1(struct magic_set *ms, const char *fn, int action)
|
|||
map = apprentice_map(ms, fn);
|
||||
if (map == NULL) {
|
||||
if (ms->flags & MAGIC_CHECK)
|
||||
file_magwarn(NULL, "using regular magic file `%s'", fn);
|
||||
file_magwarn(ms, "using regular magic file `%s'", fn);
|
||||
map = apprentice_load(ms, fn, action);
|
||||
if (map == NULL)
|
||||
return -1;
|
||||
|
@ -530,15 +534,9 @@ file_ms_free(struct magic_set *ms)
|
|||
return;
|
||||
for (i = 0; i < MAGIC_SETS; i++)
|
||||
mlist_free(ms->mlist[i]);
|
||||
if (ms->o.pbuf) {
|
||||
efree(ms->o.pbuf);
|
||||
}
|
||||
if (ms->o.buf) {
|
||||
efree(ms->o.buf);
|
||||
}
|
||||
if (ms->c.li) {
|
||||
efree(ms->c.li);
|
||||
}
|
||||
efree(ms->o.pbuf);
|
||||
efree(ms->o.buf);
|
||||
efree(ms->c.li);
|
||||
#ifdef USE_C_LOCALE
|
||||
freelocale(ms->c_lc_ctype);
|
||||
#endif
|
||||
|
@ -573,6 +571,7 @@ file_ms_alloc(int flags)
|
|||
ms->mlist[i] = NULL;
|
||||
ms->file = "unknown";
|
||||
ms->line = 0;
|
||||
ms->magwarn = 0;
|
||||
ms->indir_max = FILE_INDIR_MAX;
|
||||
ms->name_max = FILE_NAME_MAX;
|
||||
ms->elf_shnum_max = FILE_ELF_SHNUM_MAX;
|
||||
|
@ -582,6 +581,7 @@ file_ms_alloc(int flags)
|
|||
ms->regex_max = FILE_REGEX_MAX;
|
||||
ms->bytes_max = FILE_BYTES_MAX;
|
||||
ms->encoding_max = FILE_ENCODING_MAX;
|
||||
ms->magwarn_max = FILE_MAGWARN_MAX;
|
||||
#ifdef USE_C_LOCALE
|
||||
ms->c_lc_ctype = newlocale(LC_CTYPE_MASK, "C", 0);
|
||||
assert(ms->c_lc_ctype != NULL);
|
||||
|
@ -615,10 +615,7 @@ apprentice_unmap(struct magic_map *map)
|
|||
file_private struct mlist *
|
||||
mlist_alloc(void)
|
||||
{
|
||||
struct mlist *mlist;
|
||||
if ((mlist = CAST(struct mlist *, ecalloc(1, sizeof(*mlist)))) == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
struct mlist *mlist = CAST(struct mlist *, ecalloc(1, sizeof(*mlist)));
|
||||
mlist->next = mlist->prev = mlist;
|
||||
return mlist;
|
||||
}
|
||||
|
@ -662,13 +659,13 @@ mlist_free(struct mlist *mlist)
|
|||
file_protected int
|
||||
file_apprentice(struct magic_set *ms, const char *fn, int action)
|
||||
{
|
||||
char *p, *mfn;
|
||||
char *p;
|
||||
int fileerr, errs = -1;
|
||||
size_t i, j;
|
||||
size_t i;
|
||||
|
||||
(void)file_reset(ms, 0);
|
||||
|
||||
/* XXX disabling default magic loading so the compiled in data is used */
|
||||
/* XXX disabling default magic loading so the compiled in data is used */
|
||||
#if 0
|
||||
if ((fn = magic_getpath(fn, action)) == NULL)
|
||||
return -1;
|
||||
|
@ -676,36 +673,18 @@ file_apprentice(struct magic_set *ms, const char *fn, int action)
|
|||
|
||||
init_file_tables();
|
||||
|
||||
for (i = 0; i < MAGIC_SETS; i++) {
|
||||
mlist_free(ms->mlist[i]);
|
||||
ms->mlist[i] = mlist_alloc();
|
||||
}
|
||||
|
||||
if (fn == NULL)
|
||||
fn = getenv("MAGIC");
|
||||
if (fn == NULL) {
|
||||
for (i = 0; i < MAGIC_SETS; i++) {
|
||||
mlist_free(ms->mlist[i]);
|
||||
if ((ms->mlist[i] = mlist_alloc()) == NULL) {
|
||||
file_oomem(ms, sizeof(*ms->mlist[i]));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return apprentice_1(ms, fn, action);
|
||||
}
|
||||
|
||||
if ((mfn = estrdup(fn)) == NULL) {
|
||||
file_oomem(ms, strlen(fn));
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < MAGIC_SETS; i++) {
|
||||
mlist_free(ms->mlist[i]);
|
||||
if ((ms->mlist[i] = mlist_alloc()) == NULL) {
|
||||
file_oomem(ms, sizeof(*ms->mlist[0]));
|
||||
for (j = 0; j < i; j++) {
|
||||
mlist_free(ms->mlist[j]);
|
||||
ms->mlist[j] = NULL;
|
||||
}
|
||||
efree(mfn);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
char *mfn = estrdup(fn); /* modified in loop */
|
||||
fn = mfn;
|
||||
|
||||
while (fn) {
|
||||
|
@ -885,7 +864,7 @@ apprentice_magic_strength_1(const struct magic *m)
|
|||
switch (m->type) {
|
||||
case FILE_DEFAULT: /* make sure this sorts last */
|
||||
if (m->factor_op != FILE_FACTOR_OP_NONE) {
|
||||
file_magwarn(NULL, "Usupported factor_op in default %d",
|
||||
file_magwarn1("Unsupported factor_op in default %d",
|
||||
m->factor_op);
|
||||
}
|
||||
return 0;
|
||||
|
@ -1080,12 +1059,27 @@ apprentice_sort(const void *a, const void *b)
|
|||
const struct magic_entry *mb = CAST(const struct magic_entry *, b);
|
||||
size_t sa = file_magic_strength(ma->mp, ma->cont_count);
|
||||
size_t sb = file_magic_strength(mb->mp, mb->cont_count);
|
||||
if (sa == sb)
|
||||
return 0;
|
||||
else if (sa > sb)
|
||||
return -1;
|
||||
else
|
||||
return 1;
|
||||
if (sa == sb) {
|
||||
struct magic mpa = *ma->mp;
|
||||
struct magic mpb = *mb->mp;
|
||||
mpa.lineno = mpb.lineno = 0;
|
||||
int x = memcmp(&mpa, &mpb, sizeof(mpa));
|
||||
if (x == 0) {
|
||||
/* For PHP BC: don't warn */
|
||||
#if 0
|
||||
// Don't warn for DER
|
||||
if (mpa.type == FILE_DER)
|
||||
return 0;
|
||||
file_magwarn1("Duplicate magic entry `%s'",
|
||||
ma->mp->desc);
|
||||
file_mdump(ma->mp);
|
||||
file_mdump(mb->mp);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
return x > 0 ? -1 : 1;
|
||||
}
|
||||
return sa > sb ? -1 : 1;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1279,7 +1273,10 @@ load_1(struct magic_set *ms, int action, const char *fn, int *errs,
|
|||
|
||||
memset(&me, 0, sizeof(me));
|
||||
/* read and parse this file */
|
||||
for (ms->line = 1; (line = php_stream_get_line(stream, buffer , BUFSIZ, &len)) != NULL; ms->line++) {
|
||||
for (ms->line = 1; (line = php_stream_get_line(stream, buffer , BUFSIZ, &len)) != NULL;
|
||||
ms->line++) {
|
||||
if (ms->magwarn >= ms->magwarn_max)
|
||||
break;
|
||||
if (len == 0) /* null line, garbage, etc */
|
||||
continue;
|
||||
if (line[len - 1] == '\n') {
|
||||
|
@ -1324,7 +1321,7 @@ load_1(struct magic_set *ms, int action, const char *fn, int *errs,
|
|||
/*FALLTHROUGH*/
|
||||
default:
|
||||
again:
|
||||
switch (parse(ms, &me, line, lineno, action)) {
|
||||
switch (parse(ms, &me, fn, line, lineno, action)) {
|
||||
case 0:
|
||||
continue;
|
||||
case 1:
|
||||
|
@ -1961,8 +1958,8 @@ out:
|
|||
* parse one line from magic file, put into magic[index++] if valid
|
||||
*/
|
||||
file_private int
|
||||
parse(struct magic_set *ms, struct magic_entry *me, const char *line,
|
||||
size_t lineno, int action)
|
||||
parse(struct magic_set *ms, struct magic_entry *me, const char *file,
|
||||
const char *line, size_t lineno, int action)
|
||||
{
|
||||
#ifdef ENABLE_CONDITIONALS
|
||||
static uint32_t last_cont_level = 0;
|
||||
|
@ -2323,6 +2320,7 @@ parse(struct magic_set *ms, struct magic_entry *me, const char *line,
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Grab the value part, except for an 'x' reln.
|
||||
*/
|
||||
|
@ -2347,8 +2345,12 @@ parse(struct magic_set *ms, struct magic_entry *me, const char *line,
|
|||
++l;
|
||||
m->flag |= NOSPACE;
|
||||
}
|
||||
for (i = 0; (m->desc[i++] = *l++) != '\0' && i < sizeof(m->desc); )
|
||||
for (i = 0; i < sizeof(m->desc) && (m->desc[i++] = *l++) != '\0';)
|
||||
continue;
|
||||
if (m->desc[0] == '\0') {
|
||||
// Tuck in the filename for debugging.
|
||||
strlcpy(m->desc + 1, file, sizeof(m->desc) - 1);
|
||||
}
|
||||
if (i == sizeof(m->desc)) {
|
||||
m->desc[sizeof(m->desc) - 1] = '\0';
|
||||
if (ms->flags & MAGIC_CHECK)
|
||||
|
@ -2502,7 +2504,7 @@ parse_apple(struct magic_set *ms, struct magic_entry *me, const char *line,
|
|||
{
|
||||
return parse_extra(ms, me, line, len,
|
||||
CAST(off_t, offsetof(struct magic, apple)),
|
||||
sizeof(me->mp[0].apple), "APPLE", "!+-./?", 0);
|
||||
sizeof(me->mp[me->cont_count - 1].apple), "APPLE", "!+-./?", 0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2514,7 +2516,8 @@ parse_ext(struct magic_set *ms, struct magic_entry *me, const char *line,
|
|||
{
|
||||
return parse_extra(ms, me, line, len,
|
||||
CAST(off_t, offsetof(struct magic, ext)),
|
||||
sizeof(me->mp[0].ext), "EXTENSION", ",!+-/@?_$&~", 0);
|
||||
sizeof(me->mp[me->cont_count - 1].ext), "EXTENSION", ",!+-/@?_$&~",
|
||||
0);
|
||||
/* & for b&w */
|
||||
/* ~ for journal~ */
|
||||
}
|
||||
|
@ -2529,7 +2532,8 @@ parse_mime(struct magic_set *ms, struct magic_entry *me, const char *line,
|
|||
{
|
||||
return parse_extra(ms, me, line, len,
|
||||
CAST(off_t, offsetof(struct magic, mimetype)),
|
||||
sizeof(me->mp[0].mimetype), "MIME", "+-/.$?:{}", 1);
|
||||
sizeof(me->mp[me->cont_count - 1].mimetype), "MIME", "+-/.$?:{};=",
|
||||
1);
|
||||
}
|
||||
|
||||
file_private int
|
||||
|
@ -3214,12 +3218,7 @@ apprentice_map(struct magic_set *ms, const char *fn)
|
|||
php_stream *stream = NULL;
|
||||
php_stream_statbuf st;
|
||||
|
||||
|
||||
|
||||
if ((map = CAST(struct magic_map *, ecalloc(1, sizeof(*map)))) == NULL) {
|
||||
file_oomem(ms, sizeof(*map));
|
||||
return NULL;
|
||||
}
|
||||
map = CAST(struct magic_map *, ecalloc(1, sizeof(*map)));
|
||||
|
||||
if (fn == NULL) {
|
||||
map->p = (void *)&php_magic_database;
|
||||
|
@ -3426,8 +3425,8 @@ mkdbname(struct magic_set *ms, const char *fn, int strip)
|
|||
|
||||
/* Did not find .mgc, restore q */
|
||||
if (p >= ext)
|
||||
while (*q)
|
||||
q++;
|
||||
for (q = fn; *q; q++)
|
||||
continue;
|
||||
|
||||
q++;
|
||||
/* Compatibility with old code that looked in .mime */
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#include "file.h"
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$File: cdf.c,v 1.123 2022/09/24 20:30:13 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: cdf.c,v 1.124 2024/11/25 21:24:59 christos Exp $")
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
|
@ -73,7 +73,7 @@ FILE_RCSID("@(#)$File: cdf.c,v 1.123 2022/09/24 20:30:13 christos Exp $")
|
|||
#define DPRINTF(a)
|
||||
#endif
|
||||
|
||||
static union {
|
||||
file_private union {
|
||||
char s[4];
|
||||
uint32_t u;
|
||||
} cdf_bo;
|
||||
|
@ -109,7 +109,7 @@ static union {
|
|||
/*
|
||||
* swap a short
|
||||
*/
|
||||
static uint16_t
|
||||
file_private uint16_t
|
||||
_cdf_tole2(uint16_t sv)
|
||||
{
|
||||
uint16_t rv;
|
||||
|
@ -123,7 +123,7 @@ _cdf_tole2(uint16_t sv)
|
|||
/*
|
||||
* swap an int
|
||||
*/
|
||||
static uint32_t
|
||||
file_private uint32_t
|
||||
_cdf_tole4(uint32_t sv)
|
||||
{
|
||||
uint32_t rv;
|
||||
|
@ -139,7 +139,7 @@ _cdf_tole4(uint32_t sv)
|
|||
/*
|
||||
* swap a quad
|
||||
*/
|
||||
static uint64_t
|
||||
file_private uint64_t
|
||||
_cdf_tole8(uint64_t sv)
|
||||
{
|
||||
uint64_t rv;
|
||||
|
@ -161,7 +161,7 @@ _cdf_tole8(uint64_t sv)
|
|||
* grab a uint32_t from a possibly unaligned address, and return it in
|
||||
* the native host order.
|
||||
*/
|
||||
static uint32_t
|
||||
file_private uint32_t
|
||||
cdf_getuint32(const uint8_t *p, size_t offs)
|
||||
{
|
||||
uint32_t rv;
|
||||
|
@ -174,25 +174,25 @@ cdf_getuint32(const uint8_t *p, size_t offs)
|
|||
#define CDF_UNPACKA(a) \
|
||||
(void)memcpy((a), &buf[len], sizeof(a)), len += sizeof(a)
|
||||
|
||||
uint16_t
|
||||
file_protected uint16_t
|
||||
cdf_tole2(uint16_t sv)
|
||||
{
|
||||
return CDF_TOLE2(sv);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
file_protected uint32_t
|
||||
cdf_tole4(uint32_t sv)
|
||||
{
|
||||
return CDF_TOLE4(sv);
|
||||
}
|
||||
|
||||
uint64_t
|
||||
file_protected uint64_t
|
||||
cdf_tole8(uint64_t sv)
|
||||
{
|
||||
return CDF_TOLE8(sv);
|
||||
}
|
||||
|
||||
void
|
||||
file_protected void
|
||||
cdf_swap_header(cdf_header_t *h)
|
||||
{
|
||||
size_t i;
|
||||
|
@ -223,7 +223,7 @@ cdf_swap_header(cdf_header_t *h)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
file_protected void
|
||||
cdf_unpack_header(cdf_header_t *h, char *buf)
|
||||
{
|
||||
size_t i;
|
||||
|
@ -249,7 +249,7 @@ cdf_unpack_header(cdf_header_t *h, char *buf)
|
|||
CDF_UNPACK(h->h_master_sat[i]);
|
||||
}
|
||||
|
||||
void
|
||||
file_protected void
|
||||
cdf_swap_dir(cdf_directory_t *d)
|
||||
{
|
||||
d->d_namelen = CDF_TOLE2(d->d_namelen);
|
||||
|
@ -266,7 +266,7 @@ cdf_swap_dir(cdf_directory_t *d)
|
|||
d->d_size = CDF_TOLE4(d->d_size);
|
||||
}
|
||||
|
||||
void
|
||||
file_protected void
|
||||
cdf_swap_class(cdf_classid_t *d)
|
||||
{
|
||||
d->cl_dword = CDF_TOLE4(d->cl_dword);
|
||||
|
@ -274,7 +274,7 @@ cdf_swap_class(cdf_classid_t *d)
|
|||
d->cl_word[1] = CDF_TOLE2(d->cl_word[1]);
|
||||
}
|
||||
|
||||
void
|
||||
file_protected void
|
||||
cdf_unpack_dir(cdf_directory_t *d, char *buf)
|
||||
{
|
||||
size_t len = 0;
|
||||
|
@ -295,7 +295,7 @@ cdf_unpack_dir(cdf_directory_t *d, char *buf)
|
|||
CDF_UNPACK(d->d_unused0);
|
||||
}
|
||||
|
||||
int
|
||||
file_protected int
|
||||
cdf_zero_stream(cdf_stream_t *scn)
|
||||
{
|
||||
scn->sst_len = 0;
|
||||
|
@ -306,7 +306,7 @@ cdf_zero_stream(cdf_stream_t *scn)
|
|||
return -1;
|
||||
}
|
||||
|
||||
static size_t
|
||||
file_private size_t
|
||||
cdf_check_stream(const cdf_stream_t *sst, const cdf_header_t *h)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
|
@ -317,7 +317,7 @@ cdf_check_stream(const cdf_stream_t *sst, const cdf_header_t *h)
|
|||
return sst->sst_ss;
|
||||
}
|
||||
|
||||
static int
|
||||
file_private int
|
||||
cdf_check_stream_offset(const cdf_stream_t *sst, const cdf_header_t *h,
|
||||
const void *p, size_t tail, int line)
|
||||
{
|
||||
|
@ -335,7 +335,7 @@ cdf_check_stream_offset(const cdf_stream_t *sst, const cdf_header_t *h,
|
|||
return -1;
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
file_private ssize_t
|
||||
cdf_read(const cdf_info_t *info, zend_off_t off, void *buf, size_t len)
|
||||
{
|
||||
size_t siz = CAST(size_t, off + len);
|
||||
|
@ -363,7 +363,7 @@ out:
|
|||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
file_protected int
|
||||
cdf_read_header(const cdf_info_t *info, cdf_header_t *h)
|
||||
{
|
||||
char buf[512];
|
||||
|
@ -440,7 +440,7 @@ out:
|
|||
/*
|
||||
* Read the sector allocation table.
|
||||
*/
|
||||
int
|
||||
file_protected int
|
||||
cdf_read_sat(const cdf_info_t *info, cdf_header_t *h, cdf_sat_t *sat)
|
||||
{
|
||||
size_t i, j, k;
|
||||
|
@ -565,7 +565,7 @@ out:
|
|||
return CAST(size_t, -1);
|
||||
}
|
||||
|
||||
int
|
||||
file_protected int
|
||||
cdf_read_long_sector_chain(const cdf_info_t *info, const cdf_header_t *h,
|
||||
const cdf_sat_t *sat, cdf_secid_t sid, size_t len, cdf_stream_t *scn)
|
||||
{
|
||||
|
@ -614,7 +614,7 @@ out:
|
|||
return cdf_zero_stream(scn);
|
||||
}
|
||||
|
||||
int
|
||||
file_protected int
|
||||
cdf_read_short_sector_chain(const cdf_header_t *h,
|
||||
const cdf_sat_t *ssat, const cdf_stream_t *sst,
|
||||
cdf_secid_t sid, size_t len, cdf_stream_t *scn)
|
||||
|
@ -656,7 +656,7 @@ out:
|
|||
return cdf_zero_stream(scn);
|
||||
}
|
||||
|
||||
int
|
||||
file_protected int
|
||||
cdf_read_sector_chain(const cdf_info_t *info, const cdf_header_t *h,
|
||||
const cdf_sat_t *sat, const cdf_sat_t *ssat, const cdf_stream_t *sst,
|
||||
cdf_secid_t sid, size_t len, cdf_stream_t *scn)
|
||||
|
@ -669,7 +669,7 @@ cdf_read_sector_chain(const cdf_info_t *info, const cdf_header_t *h,
|
|||
return cdf_read_long_sector_chain(info, h, sat, sid, len, scn);
|
||||
}
|
||||
|
||||
int
|
||||
file_protected int
|
||||
cdf_read_dir(const cdf_info_t *info, const cdf_header_t *h,
|
||||
const cdf_sat_t *sat, cdf_dir_t *dir)
|
||||
{
|
||||
|
@ -724,7 +724,7 @@ out:
|
|||
}
|
||||
|
||||
|
||||
int
|
||||
file_protected int
|
||||
cdf_read_ssat(const cdf_info_t *info, const cdf_header_t *h,
|
||||
const cdf_sat_t *sat, cdf_sat_t *ssat)
|
||||
{
|
||||
|
@ -767,7 +767,7 @@ out1:
|
|||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
file_protected int
|
||||
cdf_read_short_stream(const cdf_info_t *info, const cdf_header_t *h,
|
||||
const cdf_sat_t *sat, const cdf_dir_t *dir, cdf_stream_t *scn,
|
||||
const cdf_directory_t **root)
|
||||
|
@ -802,7 +802,7 @@ out:
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
file_private int
|
||||
cdf_namecmp(const char *d, const uint16_t *s, size_t l)
|
||||
{
|
||||
for (; l--; d++, s++)
|
||||
|
@ -811,7 +811,7 @@ cdf_namecmp(const char *d, const uint16_t *s, size_t l)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
file_protected int
|
||||
cdf_read_doc_summary_info(const cdf_info_t *info, const cdf_header_t *h,
|
||||
const cdf_sat_t *sat, const cdf_sat_t *ssat, const cdf_stream_t *sst,
|
||||
const cdf_dir_t *dir, cdf_stream_t *scn)
|
||||
|
@ -820,7 +820,7 @@ cdf_read_doc_summary_info(const cdf_info_t *info, const cdf_header_t *h,
|
|||
"\05DocumentSummaryInformation", scn);
|
||||
}
|
||||
|
||||
int
|
||||
file_protected int
|
||||
cdf_read_summary_info(const cdf_info_t *info, const cdf_header_t *h,
|
||||
const cdf_sat_t *sat, const cdf_sat_t *ssat, const cdf_stream_t *sst,
|
||||
const cdf_dir_t *dir, cdf_stream_t *scn)
|
||||
|
@ -829,7 +829,7 @@ cdf_read_summary_info(const cdf_info_t *info, const cdf_header_t *h,
|
|||
"\05SummaryInformation", scn);
|
||||
}
|
||||
|
||||
int
|
||||
file_protected int
|
||||
cdf_read_user_stream(const cdf_info_t *info, const cdf_header_t *h,
|
||||
const cdf_sat_t *sat, const cdf_sat_t *ssat, const cdf_stream_t *sst,
|
||||
const cdf_dir_t *dir, const char *name, cdf_stream_t *scn)
|
||||
|
@ -847,7 +847,7 @@ cdf_read_user_stream(const cdf_info_t *info, const cdf_header_t *h,
|
|||
d->d_stream_first_sector, d->d_size, scn);
|
||||
}
|
||||
|
||||
int
|
||||
file_protected int
|
||||
cdf_find_stream(const cdf_dir_t *dir, const char *name, int type)
|
||||
{
|
||||
size_t i, name_len = strlen(name) + 1;
|
||||
|
@ -868,13 +868,13 @@ cdf_find_stream(const cdf_dir_t *dir, const char *name, int type)
|
|||
#define CDF_SHLEN_LIMIT (UINT32_MAX / 64)
|
||||
#define CDF_PROP_LIMIT (UINT32_MAX / (64 * sizeof(cdf_property_info_t)))
|
||||
|
||||
static const void *
|
||||
file_private const void *
|
||||
cdf_offset(const void *p, size_t l)
|
||||
{
|
||||
return CAST(const void *, CAST(const uint8_t *, p) + l);
|
||||
}
|
||||
|
||||
static const uint8_t *
|
||||
file_private const uint8_t *
|
||||
cdf_get_property_info_pos(const cdf_stream_t *sst, const cdf_header_t *h,
|
||||
const uint8_t *p, const uint8_t *e, size_t i)
|
||||
{
|
||||
|
@ -905,7 +905,7 @@ cdf_get_property_info_pos(const cdf_stream_t *sst, const cdf_header_t *h,
|
|||
return CAST(const uint8_t *, cdf_offset(CAST(const void *, p), ofs));
|
||||
}
|
||||
|
||||
static cdf_property_info_t *
|
||||
file_private cdf_property_info_t *
|
||||
cdf_grow_info(cdf_property_info_t **info, size_t *maxcount, size_t incr)
|
||||
{
|
||||
cdf_property_info_t *inp;
|
||||
|
@ -931,7 +931,7 @@ out:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
file_private int
|
||||
cdf_copy_info(cdf_property_info_t *inp, const void *p, const void *e,
|
||||
size_t len)
|
||||
{
|
||||
|
@ -959,7 +959,7 @@ cdf_copy_info(cdf_property_info_t *inp, const void *p, const void *e,
|
|||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
file_protected int
|
||||
cdf_read_property_info(const cdf_stream_t *sst, const cdf_header_t *h,
|
||||
uint32_t offs, cdf_property_info_t **info, size_t *count, size_t *maxcount)
|
||||
{
|
||||
|
@ -1116,7 +1116,7 @@ out:
|
|||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
file_protected int
|
||||
cdf_unpack_summary_info(const cdf_stream_t *sst, const cdf_header_t *h,
|
||||
cdf_summary_info_header_t *ssi, cdf_property_info_t **info, size_t *count)
|
||||
{
|
||||
|
@ -1155,7 +1155,7 @@ cdf_unpack_summary_info(const cdf_stream_t *sst, const cdf_header_t *h,
|
|||
memcpy(&cep->f, b + (l), sizeof(cep->f)); \
|
||||
ce[i].f = CAST(t, CDF_TOLE(cep->f))
|
||||
|
||||
int
|
||||
file_protected int
|
||||
cdf_unpack_catalog(const cdf_header_t *h, const cdf_stream_t *sst,
|
||||
cdf_catalog_t **cat)
|
||||
{
|
||||
|
@ -1223,7 +1223,7 @@ cdf_unpack_catalog(const cdf_header_t *h, const cdf_stream_t *sst,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
file_protected int
|
||||
cdf_print_classid(char *buf, size_t buflen, const cdf_classid_t *id)
|
||||
{
|
||||
return snprintf(buf, buflen, "%.8x-%.4x-%.4x-%.2x%.2x-"
|
||||
|
@ -1233,7 +1233,7 @@ cdf_print_classid(char *buf, size_t buflen, const cdf_classid_t *id)
|
|||
id->cl_six[5]);
|
||||
}
|
||||
|
||||
static const struct {
|
||||
file_private const struct {
|
||||
uint32_t v;
|
||||
const char *n;
|
||||
} vn[] = {
|
||||
|
@ -1259,7 +1259,7 @@ static const struct {
|
|||
{ CDF_PROPERTY_LOCALE_ID, "Locale ID" },
|
||||
};
|
||||
|
||||
int
|
||||
file_protected int
|
||||
cdf_print_property_name(char *buf, size_t bufsiz, uint32_t p)
|
||||
{
|
||||
size_t i;
|
||||
|
@ -1270,7 +1270,7 @@ cdf_print_property_name(char *buf, size_t bufsiz, uint32_t p)
|
|||
return snprintf(buf, bufsiz, "%#x", p);
|
||||
}
|
||||
|
||||
int
|
||||
file_protected int
|
||||
cdf_print_elapsed_time(char *buf, size_t bufsiz, cdf_timestamp_t ts)
|
||||
{
|
||||
int len = 0;
|
||||
|
@ -1305,7 +1305,7 @@ cdf_print_elapsed_time(char *buf, size_t bufsiz, cdf_timestamp_t ts)
|
|||
return len;
|
||||
}
|
||||
|
||||
char *
|
||||
file_protected char *
|
||||
cdf_u16tos8(char *buf, size_t len, const uint16_t *p)
|
||||
{
|
||||
size_t i;
|
||||
|
@ -1316,7 +1316,7 @@ cdf_u16tos8(char *buf, size_t len, const uint16_t *p)
|
|||
}
|
||||
|
||||
#ifdef CDF_DEBUG
|
||||
void
|
||||
file_protected void
|
||||
cdf_dump_header(const cdf_header_t *h)
|
||||
{
|
||||
size_t i;
|
||||
|
@ -1344,7 +1344,7 @@ cdf_dump_header(const cdf_header_t *h)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
file_protected void
|
||||
cdf_dump_sat(const char *prefix, const cdf_sat_t *sat, size_t size)
|
||||
{
|
||||
size_t i, j, s = size / sizeof(cdf_secid_t);
|
||||
|
@ -1363,7 +1363,7 @@ cdf_dump_sat(const char *prefix, const cdf_sat_t *sat, size_t size)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
file_protected void
|
||||
cdf_dump(const void *v, size_t len)
|
||||
{
|
||||
size_t i, j;
|
||||
|
@ -1384,14 +1384,14 @@ cdf_dump(const void *v, size_t len)
|
|||
(void)fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
void
|
||||
file_protected void
|
||||
cdf_dump_stream(const cdf_stream_t *sst)
|
||||
{
|
||||
size_t ss = sst->sst_ss;
|
||||
cdf_dump(sst->sst_tab, ss * sst->sst_len);
|
||||
}
|
||||
|
||||
void
|
||||
file_protected void
|
||||
cdf_dump_dir(const cdf_info_t *info, const cdf_header_t *h,
|
||||
const cdf_sat_t *sat, const cdf_sat_t *ssat, const cdf_stream_t *sst,
|
||||
const cdf_dir_t *dir)
|
||||
|
@ -1451,7 +1451,7 @@ cdf_dump_dir(const cdf_info_t *info, const cdf_header_t *h,
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
file_protected void
|
||||
cdf_dump_property_info(const cdf_property_info_t *info, size_t count)
|
||||
{
|
||||
cdf_timestamp_t tp;
|
||||
|
@ -1521,7 +1521,7 @@ cdf_dump_property_info(const cdf_property_info_t *info, size_t count)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
file_protected void
|
||||
cdf_dump_summary_info(const cdf_header_t *h, const cdf_stream_t *sst)
|
||||
{
|
||||
char buf[128];
|
||||
|
@ -1544,7 +1544,7 @@ cdf_dump_summary_info(const cdf_header_t *h, const cdf_stream_t *sst)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
file_protected void
|
||||
cdf_dump_catalog(const cdf_header_t *h, const cdf_stream_t *sst)
|
||||
{
|
||||
cdf_catalog_t *cat;
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include "file.h"
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$File: cdf_time.c,v 1.24 2023/07/17 15:54:44 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: cdf_time.c,v 1.25 2024/11/25 21:24:59 christos Exp $")
|
||||
#endif
|
||||
|
||||
#include <time.h>
|
||||
|
@ -41,14 +41,14 @@ FILE_RCSID("@(#)$File: cdf_time.c,v 1.24 2023/07/17 15:54:44 christos Exp $")
|
|||
#define isleap(y) ((((y) % 4) == 0) && \
|
||||
((((y) % 100) != 0) || (((y) % 400) == 0)))
|
||||
|
||||
static const int mdays[] = {
|
||||
file_private const int mdays[] = {
|
||||
31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
|
||||
};
|
||||
|
||||
/*
|
||||
* Return the number of days between jan 01 1601 and jan 01 of year.
|
||||
*/
|
||||
static int
|
||||
file_private int
|
||||
cdf_getdays(int year)
|
||||
{
|
||||
int days = 0;
|
||||
|
@ -63,7 +63,7 @@ cdf_getdays(int year)
|
|||
/*
|
||||
* Return the day within the month
|
||||
*/
|
||||
static int
|
||||
file_private int
|
||||
cdf_getday(int year, int days)
|
||||
{
|
||||
size_t m;
|
||||
|
@ -80,7 +80,7 @@ cdf_getday(int year, int days)
|
|||
/*
|
||||
* Return the 0...11 month number.
|
||||
*/
|
||||
static int
|
||||
file_private int
|
||||
cdf_getmonth(int year, int days)
|
||||
{
|
||||
size_t m;
|
||||
|
@ -95,12 +95,12 @@ cdf_getmonth(int year, int days)
|
|||
return CAST(int, m);
|
||||
}
|
||||
|
||||
int
|
||||
file_protected int
|
||||
cdf_timestamp_to_timespec(struct timespec *ts, cdf_timestamp_t t)
|
||||
{
|
||||
struct tm tm;
|
||||
#ifdef HAVE_STRUCT_TM_TM_ZONE
|
||||
static char UTC[] = "UTC";
|
||||
file_private char UTC[] = "UTC";
|
||||
#endif
|
||||
int rdays;
|
||||
|
||||
|
@ -142,7 +142,7 @@ cdf_timestamp_to_timespec(struct timespec *ts, cdf_timestamp_t t)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
file_protected int
|
||||
/*ARGSUSED*/
|
||||
cdf_timespec_to_timestamp(cdf_timestamp_t *t, const struct timespec *ts)
|
||||
{
|
||||
|
@ -165,7 +165,7 @@ cdf_timespec_to_timestamp(cdf_timestamp_t *t, const struct timespec *ts)
|
|||
return 0;
|
||||
}
|
||||
|
||||
char *
|
||||
file_protected char *
|
||||
cdf_ctime(const time_t *sec, char *buf)
|
||||
{
|
||||
char *ptr = *sec > MAX_CTIME ? NULL : ctime_r(sec, buf);
|
||||
|
@ -188,8 +188,8 @@ main(int argc, char *argv[])
|
|||
{
|
||||
struct timespec ts;
|
||||
char buf[25];
|
||||
static const cdf_timestamp_t tst = 0x01A5E403C2D59C00ULL;
|
||||
static const char *ref = "Sat Apr 23 01:30:00 1977";
|
||||
file_private const cdf_timestamp_t tst = 0x01A5E403C2D59C00ULL;
|
||||
file_private const char *ref = "Sat Apr 23 01:30:00 1977";
|
||||
char *p, *q;
|
||||
|
||||
cdf_timestamp_to_timespec(&ts, tst);
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#include "file.h"
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$File: compress.c,v 1.157 2023/05/21 15:59:58 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: compress.c,v 1.158 2024/11/10 16:52:27 christos Exp $")
|
||||
#endif
|
||||
|
||||
#include "magic.h"
|
||||
|
@ -46,6 +46,7 @@ FILE_RCSID("@(#)$File: compress.c,v 1.157 2023/05/21 15:59:58 christos Exp $")
|
|||
#ifdef HAVE_SPAWN_H
|
||||
#include <spawn.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
|
@ -189,6 +190,7 @@ file_private const struct {
|
|||
#define METH_BZIP 7
|
||||
#define METH_XZ 9
|
||||
#define METH_LZIP 8
|
||||
#define METH_LRZIP 10
|
||||
#define METH_ZSTD 12
|
||||
#define METH_LZMA 13
|
||||
#define METH_ZLIB 14
|
||||
|
@ -247,6 +249,7 @@ file_private int uncompresslzlib(const unsigned char *, unsigned char **, size_t
|
|||
size_t *, int);
|
||||
#endif
|
||||
|
||||
|
||||
static int makeerror(unsigned char **, size_t *, const char *, ...)
|
||||
__attribute__((__format__(__printf__, 3, 4)));
|
||||
file_private const char *methodname(size_t);
|
||||
|
@ -833,7 +836,6 @@ err:
|
|||
}
|
||||
#endif
|
||||
|
||||
|
||||
static int
|
||||
makeerror(unsigned char **buf, size_t *len, const char *fmt, ...)
|
||||
{
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#include "file.h"
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$File: der.c,v 1.27 2022/09/24 20:30:13 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: der.c,v 1.28 2024/11/25 22:31:53 christos Exp $")
|
||||
#endif
|
||||
#else
|
||||
#define SIZE_T_FORMAT "z"
|
||||
|
@ -134,20 +134,20 @@ static const char *der__tag[] = {
|
|||
#endif
|
||||
|
||||
#ifdef TEST_DER
|
||||
static uint8_t
|
||||
file_private uint8_t
|
||||
getclass(uint8_t c)
|
||||
{
|
||||
return c >> 6;
|
||||
}
|
||||
|
||||
static uint8_t
|
||||
file_private uint8_t
|
||||
gettype(uint8_t c)
|
||||
{
|
||||
return (c >> 5) & 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
static uint32_t
|
||||
file_private uint32_t
|
||||
gettag(const uint8_t *c, size_t *p, size_t l)
|
||||
{
|
||||
uint32_t tag;
|
||||
|
@ -180,7 +180,7 @@ gettag(const uint8_t *c, size_t *p, size_t l)
|
|||
* Returns the length, or DER_BAD if the end of the input is reached or the
|
||||
* length exceeds the remaining input.
|
||||
*/
|
||||
static uint32_t
|
||||
file_private uint32_t
|
||||
getlength(const uint8_t *c, size_t *p, size_t l)
|
||||
{
|
||||
uint8_t digits, i;
|
||||
|
@ -223,7 +223,7 @@ getlength(const uint8_t *c, size_t *p, size_t l)
|
|||
return CAST(uint32_t, len);
|
||||
}
|
||||
|
||||
static const char *
|
||||
file_private const char *
|
||||
der_tag(char *buf, size_t len, uint32_t tag)
|
||||
{
|
||||
if (tag < DER_TAG_LAST)
|
||||
|
@ -234,7 +234,7 @@ der_tag(char *buf, size_t len, uint32_t tag)
|
|||
}
|
||||
|
||||
#ifndef TEST_DER
|
||||
static int
|
||||
file_private int
|
||||
der_data(char *buf, size_t blen, uint32_t tag, const void *q, uint32_t len)
|
||||
{
|
||||
uint32_t i;
|
||||
|
@ -262,7 +262,7 @@ der_data(char *buf, size_t blen, uint32_t tag, const void *q, uint32_t len)
|
|||
return len * 2;
|
||||
}
|
||||
|
||||
int32_t
|
||||
file_protected int32_t
|
||||
der_offs(struct magic_set *ms, struct magic *m, size_t nbytes)
|
||||
{
|
||||
const uint8_t *b = RCAST(const uint8_t *, ms->search.s);
|
||||
|
@ -301,7 +301,7 @@ der_offs(struct magic_set *ms, struct magic *m, size_t nbytes)
|
|||
return CAST(int32_t, offs);
|
||||
}
|
||||
|
||||
int
|
||||
file_protected int
|
||||
der_cmp(struct magic_set *ms, struct magic *m)
|
||||
{
|
||||
const uint8_t *b = RCAST(const uint8_t *, ms->search.s);
|
||||
|
@ -384,7 +384,7 @@ val:
|
|||
#endif
|
||||
|
||||
#ifdef TEST_DER
|
||||
static void
|
||||
file_private void
|
||||
printtag(uint32_t tag, const void *q, uint32_t len)
|
||||
{
|
||||
const uint8_t *d = q;
|
||||
|
@ -404,7 +404,7 @@ printtag(uint32_t tag, const void *q, uint32_t len)
|
|||
printf("\n");
|
||||
}
|
||||
|
||||
static void
|
||||
file_private void
|
||||
printdata(size_t level, const void *v, size_t x, size_t l)
|
||||
{
|
||||
const uint8_t *p = v, *ep = p + l;
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#include "file.h"
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$File: encoding.c,v 1.42 2022/12/26 17:31:14 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: encoding.c,v 1.43 2024/10/29 20:56:48 christos Exp $")
|
||||
#endif /* lint */
|
||||
|
||||
#include "magic.h"
|
||||
|
@ -334,7 +334,7 @@ static const uint8_t first[] = {
|
|||
|
||||
// acceptRange gives the range of valid values for the second byte in a UTF-8
|
||||
// sequence.
|
||||
struct accept_range {
|
||||
static struct accept_range {
|
||||
uint8_t lo; // lowest value for second byte.
|
||||
uint8_t hi; // highest value for second byte.
|
||||
} accept_ranges[16] = {
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
*/
|
||||
/*
|
||||
* file.h - definitions for file(1) program
|
||||
* @(#)$File: file.h,v 1.248 2023/07/28 14:38:25 christos Exp $
|
||||
* @(#)$File: file.h,v 1.257 2024/11/25 22:31:53 christos Exp $
|
||||
*/
|
||||
|
||||
#ifndef __file_h__
|
||||
|
@ -100,16 +100,23 @@
|
|||
|
||||
#define file_private static
|
||||
|
||||
#if HAVE_VISIBILITY && !defined(WIN32)
|
||||
#define file_public __attribute__ ((__visibility__("default")))
|
||||
#ifndef file_protected
|
||||
#define file_protected __attribute__ ((__visibility__("hidden")))
|
||||
#endif
|
||||
#if HAVE_VISIBILITY
|
||||
# if defined(WIN32)
|
||||
# define file_public __declspec(dllexport)
|
||||
# ifndef file_protected
|
||||
# define file_protected
|
||||
# endif
|
||||
# else
|
||||
# define file_public __attribute__((__visibility__("default")))
|
||||
# ifndef file_protected
|
||||
# define file_protected __attribute__((__visibility__("hidden")))
|
||||
# endif
|
||||
# endif
|
||||
#else
|
||||
#define file_public
|
||||
#ifndef file_protected
|
||||
#define file_protected
|
||||
#endif
|
||||
# define file_public
|
||||
# ifndef file_protected
|
||||
# define file_protected
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef __arraycount
|
||||
|
@ -161,11 +168,12 @@
|
|||
#define FILE_BADSIZE CAST(size_t, ~0ul)
|
||||
#define MAXDESC 64 /* max len of text description/MIME type */
|
||||
#define MAXMIME 80 /* max len of text MIME type */
|
||||
#define MAXEXT 120 /* max len of text extensions */
|
||||
#define MAXstring 128 /* max len of "string" types */
|
||||
|
||||
#define MAGICNO 0xF11E041C
|
||||
#define VERSIONNO 18
|
||||
#define FILE_MAGICSIZE 376
|
||||
#define VERSIONNO 19
|
||||
#define FILE_MAGICSIZE 432
|
||||
|
||||
#define FILE_GUID_SIZE sizeof("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")
|
||||
|
||||
|
@ -365,7 +373,7 @@ struct magic {
|
|||
/* Words 61-62 */
|
||||
char apple[8]; /* APPLE CREATOR/TYPE */
|
||||
/* Words 63-78 */
|
||||
char ext[64]; /* Popular extensions */
|
||||
char ext[MAXEXT]; /* Popular extensions from old 64 raised by 56 for sqlite/sqlite3/... */
|
||||
};
|
||||
|
||||
#define BIT(A) (1 << (A))
|
||||
|
@ -462,6 +470,7 @@ struct magic_set {
|
|||
const char *file;
|
||||
size_t line; /* current magic line number */
|
||||
mode_t mode; /* copy of current stat mode */
|
||||
uint16_t magwarn; /* current number of warnings */
|
||||
|
||||
/* data for searches */
|
||||
struct {
|
||||
|
@ -480,9 +489,10 @@ struct magic_set {
|
|||
uint16_t elf_phnum_max;
|
||||
uint16_t elf_notes_max;
|
||||
uint16_t regex_max;
|
||||
uint16_t magwarn_max;
|
||||
size_t bytes_max; /* number of bytes to read from file */
|
||||
size_t encoding_max; /* bytes to look for encoding */
|
||||
size_t elf_shsize_max;
|
||||
size_t elf_shsize_max;
|
||||
#ifndef FILE_BYTES_MAX
|
||||
# define FILE_BYTES_MAX (7 * 1024 * 1024)/* how much of the file to look at */
|
||||
#endif /* above 0x6ab0f4 map offset for HelveticaNeue.dfont */
|
||||
|
@ -491,9 +501,10 @@ struct magic_set {
|
|||
#define FILE_ELF_SHNUM_MAX 32768
|
||||
#define FILE_ELF_SHSIZE_MAX (128 * 1024 * 1024)
|
||||
#define FILE_INDIR_MAX 50
|
||||
#define FILE_NAME_MAX 50
|
||||
#define FILE_NAME_MAX 100
|
||||
#define FILE_REGEX_MAX 8192
|
||||
#define FILE_ENCODING_MAX (64 * 1024)
|
||||
#define FILE_MAGWARN_MAX 64
|
||||
#if defined(HAVE_NEWLOCALE) && defined(HAVE_USELOCALE) && defined(HAVE_FREELOCALE)
|
||||
#define USE_C_LOCALE
|
||||
locale_t c_lc_ctype;
|
||||
|
@ -573,6 +584,8 @@ file_protected void file_magerror(struct magic_set *, const char *, ...)
|
|||
__attribute__((__format__(__printf__, 2, 3)));
|
||||
file_protected void file_magwarn(struct magic_set *, const char *, ...)
|
||||
__attribute__((__format__(__printf__, 2, 3)));
|
||||
file_protected void file_magwarn1(const char *, ...)
|
||||
__attribute__((__format__(__printf__, 1, 2)));
|
||||
file_protected void file_mdump(struct magic *);
|
||||
file_protected void file_showstr(FILE *, const char *, size_t);
|
||||
file_protected size_t file_mbswidth(struct magic_set *, const char *);
|
||||
|
@ -612,14 +625,14 @@ file_protected file_pushbuf_t *file_push_buffer(struct magic_set *);
|
|||
file_protected char *file_pop_buffer(struct magic_set *, file_pushbuf_t *);
|
||||
|
||||
#ifndef COMPILE_ONLY
|
||||
extern const char *file_names[];
|
||||
extern const size_t file_nnames;
|
||||
extern file_protected const char *file_names[];
|
||||
extern file_protected const size_t file_nnames;
|
||||
#endif
|
||||
|
||||
#ifndef strlcpy
|
||||
#ifndef HAVE_STRLCPY
|
||||
size_t strlcpy(char *, const char *, size_t);
|
||||
#endif
|
||||
#ifndef strlcat
|
||||
#ifndef HAVE_STRLCAT
|
||||
size_t strlcat(char *, const char *, size_t);
|
||||
#endif
|
||||
#ifndef HAVE_STRCASESTR
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include "file.h"
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$File: funcs.c,v 1.140 2023/05/21 17:08:34 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: funcs.c,v 1.142 2023/07/30 14:41:14 christos Exp $")
|
||||
#endif /* lint */
|
||||
|
||||
#include "magic.h"
|
||||
|
@ -662,13 +662,13 @@ file_replace(struct magic_set *ms, const char *pat, const char *rep)
|
|||
size_t rep_cnt = 0;
|
||||
|
||||
opts |= PCRE2_MULTILINE;
|
||||
pattern = convert_libmagic_pattern((char*)pat, strlen(pat), opts);
|
||||
if ((pce = pcre_get_compiled_regex_cache_ex(pattern, 0)) == NULL) {
|
||||
zend_string_release(pattern);
|
||||
pattern = convert_libmagic_pattern(pat, strlen(pat), opts);
|
||||
pce = pcre_get_compiled_regex_cache_ex(pattern, 0);
|
||||
zend_string_release_ex(pattern, 0);
|
||||
if (pce == NULL) {
|
||||
rep_cnt = -1;
|
||||
goto out;
|
||||
}
|
||||
zend_string_release(pattern);
|
||||
|
||||
repl = zend_string_init(rep, strlen(rep), 0);
|
||||
res = php_pcre_replace_impl(pce, NULL, ms->o.buf, strlen(ms->o.buf), repl, -1, &rep_cnt);
|
||||
|
|
|
@ -32,12 +32,13 @@
|
|||
#include "file.h"
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$File: is_csv.c,v 1.13 2023/07/17 16:08:17 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: is_csv.c,v 1.15 2024/05/18 15:16:13 christos Exp $")
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include "magic.h"
|
||||
#else
|
||||
#define CAST(a, b) ((a)(b))
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
|
@ -107,7 +108,7 @@ csv_parse(const unsigned char *uc, const unsigned char *ue)
|
|||
nl++;
|
||||
#if CSV_LINES
|
||||
if (nl == CSV_LINES)
|
||||
return tf != 0 && tf == nf;
|
||||
return tf > 1 && tf == nf;
|
||||
#endif
|
||||
if (tf == 0) {
|
||||
// First time and no fields, give up
|
||||
|
@ -125,7 +126,7 @@ csv_parse(const unsigned char *uc, const unsigned char *ue)
|
|||
break;
|
||||
}
|
||||
}
|
||||
return tf && nl >= 2;
|
||||
return tf > 1 && nl >= 2;
|
||||
}
|
||||
|
||||
#ifndef TEST
|
||||
|
@ -186,7 +187,7 @@ main(int argc, char *argv[])
|
|||
if (fstat(fd, &st) == -1)
|
||||
err(EXIT_FAILURE, "Can't stat `%s'", argv[1]);
|
||||
|
||||
if ((p = CAST(char *, malloc(st.st_size))) == NULL)
|
||||
if ((p = CAST(unsigned char *, malloc(st.st_size))) == NULL)
|
||||
err(EXIT_FAILURE, "Can't allocate %jd bytes",
|
||||
(intmax_t)st.st_size);
|
||||
if (read(fd, p, st.st_size) != st.st_size)
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include "file.h"
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$File: magic.c,v 1.121 2023/02/09 17:45:19 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: magic.c,v 1.123 2023/12/29 18:04:48 christos Exp $")
|
||||
#endif /* lint */
|
||||
|
||||
#include "magic.h"
|
||||
|
@ -335,33 +335,37 @@ magic_setparam(struct magic_set *ms, int param, const void *val)
|
|||
{
|
||||
if (ms == NULL)
|
||||
return -1;
|
||||
const size_t v = *CAST(const size_t *, val);
|
||||
switch (param) {
|
||||
case MAGIC_PARAM_INDIR_MAX:
|
||||
ms->indir_max = CAST(uint16_t, *CAST(const size_t *, val));
|
||||
ms->indir_max = CAST(uint16_t, v);
|
||||
return 0;
|
||||
case MAGIC_PARAM_NAME_MAX:
|
||||
ms->name_max = CAST(uint16_t, *CAST(const size_t *, val));
|
||||
ms->name_max = CAST(uint16_t, v);
|
||||
return 0;
|
||||
case MAGIC_PARAM_ELF_PHNUM_MAX:
|
||||
ms->elf_phnum_max = CAST(uint16_t, *CAST(const size_t *, val));
|
||||
ms->elf_phnum_max = CAST(uint16_t, v);
|
||||
return 0;
|
||||
case MAGIC_PARAM_ELF_SHNUM_MAX:
|
||||
ms->elf_shnum_max = CAST(uint16_t, *CAST(const size_t *, val));
|
||||
ms->elf_shnum_max = CAST(uint16_t, v);
|
||||
return 0;
|
||||
case MAGIC_PARAM_ELF_SHSIZE_MAX:
|
||||
ms->elf_shsize_max = *CAST(const size_t *, val);
|
||||
ms->elf_shsize_max = v;
|
||||
return 0;
|
||||
case MAGIC_PARAM_ELF_NOTES_MAX:
|
||||
ms->elf_notes_max = CAST(uint16_t, *CAST(const size_t *, val));
|
||||
ms->elf_notes_max = CAST(uint16_t, v);
|
||||
return 0;
|
||||
case MAGIC_PARAM_REGEX_MAX:
|
||||
ms->regex_max = CAST(uint16_t, *CAST(const size_t *, val));
|
||||
ms->regex_max = CAST(uint16_t, v);
|
||||
return 0;
|
||||
case MAGIC_PARAM_BYTES_MAX:
|
||||
ms->bytes_max = *CAST(const size_t *, val);
|
||||
ms->bytes_max = v;
|
||||
return 0;
|
||||
case MAGIC_PARAM_ENCODING_MAX:
|
||||
ms->encoding_max = *CAST(const size_t *, val);
|
||||
ms->encoding_max = v;
|
||||
return 0;
|
||||
case MAGIC_PARAM_MAGWARN_MAX:
|
||||
ms->magwarn_max = v;
|
||||
return 0;
|
||||
default:
|
||||
errno = EINVAL;
|
||||
|
@ -402,6 +406,9 @@ magic_getparam(struct magic_set *ms, int param, void *val)
|
|||
case MAGIC_PARAM_ENCODING_MAX:
|
||||
*CAST(size_t *, val) = ms->encoding_max;
|
||||
return 0;
|
||||
case MAGIC_PARAM_MAGWARN_MAX:
|
||||
*CAST(size_t *, val) = ms->magwarn_max;
|
||||
return 0;
|
||||
default:
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
|
|
|
@ -95,7 +95,7 @@ b\13apple\0\
|
|||
b\14no_check_compress\0\
|
||||
b\15no_check_tar\0\
|
||||
b\16no_check_soft\0\
|
||||
b\17no_check_sapptype\0\
|
||||
b\17no_check_apptype\0\
|
||||
b\20no_check_elf\0\
|
||||
b\21no_check_text\0\
|
||||
b\22no_check_cdf\0\
|
||||
|
@ -115,7 +115,7 @@ b\31transp_compression\0\
|
|||
#define MAGIC_NO_CHECK_FORTRAN 0x000000 /* Don't check ascii/fortran */
|
||||
#define MAGIC_NO_CHECK_TROFF 0x000000 /* Don't check ascii/troff */
|
||||
|
||||
#define MAGIC_VERSION 545 /* This implementation */
|
||||
#define MAGIC_VERSION 546 /* This implementation */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include "file.h"
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$File: print.c,v 1.99 2023/07/17 16:40:57 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: print.c,v 1.106 2024/09/01 13:50:01 christos Exp $")
|
||||
#endif /* lint */
|
||||
|
||||
#include <string.h>
|
||||
|
@ -52,7 +52,8 @@ file_mdump(struct magic *m)
|
|||
static const char optyp[] = { FILE_OPS };
|
||||
char tbuf[256];
|
||||
|
||||
(void) fprintf(stderr, "%u: %.*s %d", m->lineno,
|
||||
(void) fprintf(stderr, "%s, %u: %.*s %d",
|
||||
m->desc[0] == '\0' ? m->desc + 1 : "*unknown*", m->lineno,
|
||||
(m->cont_level & 7) + 1, ">>>>>>>>", m->offset);
|
||||
|
||||
if (m->flag & INDIR) {
|
||||
|
@ -241,17 +242,11 @@ file_mdump(struct magic *m)
|
|||
}
|
||||
#endif
|
||||
|
||||
/*VARARGS*/
|
||||
file_protected void
|
||||
file_magwarn(struct magic_set *ms, const char *f, ...)
|
||||
static void __attribute__((__format__(__printf__, 1, 0)))
|
||||
file_vmagwarn(const char *f, va_list va)
|
||||
{
|
||||
va_list va;
|
||||
char *expanded_format = NULL;
|
||||
int expanded_len;
|
||||
|
||||
va_start(va, f);
|
||||
expanded_len = vasprintf(&expanded_format, f, va);
|
||||
va_end(va);
|
||||
int expanded_len = vasprintf(&expanded_format, f, va);
|
||||
|
||||
if (expanded_len >= 0 && expanded_format) {
|
||||
php_error_docref(NULL, E_WARNING, "%s", expanded_format);
|
||||
|
@ -260,6 +255,32 @@ file_magwarn(struct magic_set *ms, const char *f, ...)
|
|||
}
|
||||
}
|
||||
|
||||
/*VARARGS*/
|
||||
file_protected void
|
||||
file_magwarn1(const char *f, ...)
|
||||
{
|
||||
va_list va;
|
||||
|
||||
va_start(va, f);
|
||||
file_vmagwarn(f, va);
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
|
||||
/*VARARGS*/
|
||||
file_protected void
|
||||
file_magwarn(struct magic_set *ms, const char *f, ...)
|
||||
{
|
||||
/* Upstream has a check here: ++ms->magwarn == ms->magwarn_max,
|
||||
* but for PHP BC we keep emitting all warnings and
|
||||
* letting the user control the output behaviour. */
|
||||
va_list va;
|
||||
|
||||
va_start(va, f);
|
||||
file_vmagwarn(f, va);
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
file_protected const char *
|
||||
file_fmtvarint(char *buf, size_t blen, const unsigned char *us, int t)
|
||||
{
|
||||
|
@ -289,6 +310,7 @@ file_fmtdatetime(char *buf, size_t bsize, uint64_t v, int flags)
|
|||
goto out;
|
||||
|
||||
if (flags & FILE_T_LOCAL) {
|
||||
tzset();
|
||||
tm = php_localtime_r(&t, &tmz);
|
||||
} else {
|
||||
tm = php_gmtime_r(&t, &tmz);
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include "file.h"
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$File: softmagic.c,v 1.345 2023/07/02 12:48:39 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: softmagic.c,v 1.349 2024/11/10 18:33:17 christos Exp $")
|
||||
#endif /* lint */
|
||||
|
||||
#include "magic.h"
|
||||
|
@ -56,8 +56,8 @@ file_private int msetoffset(struct magic_set *, struct magic *, struct buffer *,
|
|||
const struct buffer *, size_t, unsigned int);
|
||||
file_private int magiccheck(struct magic_set *, struct magic *);
|
||||
file_private int mprint(struct magic_set *, struct magic *);
|
||||
file_private int moffset(struct magic_set *, struct magic *, const struct buffer *,
|
||||
int32_t *);
|
||||
file_private int moffset(struct magic_set *, struct magic *,
|
||||
const struct buffer *, size_t, int32_t *);
|
||||
file_private void mdebug(uint32_t, const char *, size_t);
|
||||
file_private int mcopy(struct magic_set *, union VALUETYPE *, int, int,
|
||||
const unsigned char *, uint32_t, size_t, struct magic *);
|
||||
|
@ -71,41 +71,41 @@ file_private int cvt_64(union VALUETYPE *, const struct magic *);
|
|||
|
||||
#define OFFSET_OOB(n, o, i) ((n) < CAST(uint32_t, (o)) || (i) > ((n) - (o)))
|
||||
#define BE64(p) ( \
|
||||
(CAST(uint64_t, (p)->hq[0])<<56)| \
|
||||
(CAST(uint64_t, (p)->hq[1])<<48)| \
|
||||
(CAST(uint64_t, (p)->hq[2])<<40)| \
|
||||
(CAST(uint64_t, (p)->hq[3])<<32)| \
|
||||
(CAST(uint64_t, (p)->hq[4])<<24)| \
|
||||
(CAST(uint64_t, (p)->hq[5])<<16)| \
|
||||
(CAST(uint64_t, (p)->hq[6])<<8)| \
|
||||
(CAST(uint64_t, (p)->hq[7])))
|
||||
(CAST(uint64_t, (p)[0])<<56)| \
|
||||
(CAST(uint64_t, (p)[1])<<48)| \
|
||||
(CAST(uint64_t, (p)[2])<<40)| \
|
||||
(CAST(uint64_t, (p)[3])<<32)| \
|
||||
(CAST(uint64_t, (p)[4])<<24)| \
|
||||
(CAST(uint64_t, (p)[5])<<16)| \
|
||||
(CAST(uint64_t, (p)[6])<<8)| \
|
||||
(CAST(uint64_t, (p)[7])))
|
||||
#define LE64(p) ( \
|
||||
(CAST(uint64_t, (p)->hq[7])<<56)| \
|
||||
(CAST(uint64_t, (p)->hq[6])<<48)| \
|
||||
(CAST(uint64_t, (p)->hq[5])<<40)| \
|
||||
(CAST(uint64_t, (p)->hq[4])<<32)| \
|
||||
(CAST(uint64_t, (p)->hq[3])<<24)| \
|
||||
(CAST(uint64_t, (p)->hq[2])<<16)| \
|
||||
(CAST(uint64_t, (p)->hq[1])<<8)| \
|
||||
(CAST(uint64_t, (p)->hq[0])))
|
||||
(CAST(uint64_t, (p)[7])<<56)| \
|
||||
(CAST(uint64_t, (p)[6])<<48)| \
|
||||
(CAST(uint64_t, (p)[5])<<40)| \
|
||||
(CAST(uint64_t, (p)[4])<<32)| \
|
||||
(CAST(uint64_t, (p)[3])<<24)| \
|
||||
(CAST(uint64_t, (p)[2])<<16)| \
|
||||
(CAST(uint64_t, (p)[1])<<8)| \
|
||||
(CAST(uint64_t, (p)[0])))
|
||||
#define LE32(p) ( \
|
||||
(CAST(uint32_t, (p)->hl[3])<<24)| \
|
||||
(CAST(uint32_t, (p)->hl[2])<<16)| \
|
||||
(CAST(uint32_t, (p)->hl[1])<<8)| \
|
||||
(CAST(uint32_t, (p)->hl[0])))
|
||||
(CAST(uint32_t, (p)[3])<<24)| \
|
||||
(CAST(uint32_t, (p)[2])<<16)| \
|
||||
(CAST(uint32_t, (p)[1])<<8)| \
|
||||
(CAST(uint32_t, (p)[0])))
|
||||
#define BE32(p) ( \
|
||||
(CAST(uint32_t, (p)->hl[0])<<24)| \
|
||||
(CAST(uint32_t, (p)->hl[1])<<16)| \
|
||||
(CAST(uint32_t, (p)->hl[2])<<8)| \
|
||||
(CAST(uint32_t, (p)->hl[3])))
|
||||
(CAST(uint32_t, (p)[0])<<24)| \
|
||||
(CAST(uint32_t, (p)[1])<<16)| \
|
||||
(CAST(uint32_t, (p)[2])<<8)| \
|
||||
(CAST(uint32_t, (p)[3])))
|
||||
#define ME32(p) ( \
|
||||
(CAST(uint32_t, (p)->hl[1])<<24)| \
|
||||
(CAST(uint32_t, (p)->hl[0])<<16)| \
|
||||
(CAST(uint32_t, (p)->hl[3])<<8)| \
|
||||
(CAST(uint32_t, (p)->hl[2])))
|
||||
(CAST(uint32_t, (p)[1])<<24)| \
|
||||
(CAST(uint32_t, (p)[0])<<16)| \
|
||||
(CAST(uint32_t, (p)[3])<<8)| \
|
||||
(CAST(uint32_t, (p)[2])))
|
||||
|
||||
#define BE16(p) ((CAST(uint16_t, (p)->hs[0])<<8)|(CAST(uint16_t, (p)->hs[1])))
|
||||
#define LE16(p) ((CAST(uint16_t, (p)->hs[1])<<8)|(CAST(uint16_t, (p)->hs[0])))
|
||||
#define BE16(p) ((CAST(uint16_t, (p)[0])<<8)|(CAST(uint16_t, (p)[1])))
|
||||
#define LE16(p) ((CAST(uint16_t, (p)[1])<<8)|(CAST(uint16_t, (p)[0])))
|
||||
#define SEXT(s,v,p) ((s) ? \
|
||||
CAST(intmax_t, CAST(int##v##_t, p)) : \
|
||||
CAST(intmax_t, CAST(uint##v##_t, p)))
|
||||
|
@ -322,7 +322,7 @@ flush:
|
|||
}
|
||||
}
|
||||
|
||||
switch (moffset(ms, m, &bb, &ms->c.li[cont_level].off)) {
|
||||
switch (moffset(ms, m, &bb, offset, &ms->c.li[cont_level].off)) {
|
||||
case -1:
|
||||
case 0:
|
||||
goto flush;
|
||||
|
@ -451,7 +451,7 @@ flush:
|
|||
*need_separator = 1;
|
||||
}
|
||||
|
||||
switch (moffset(ms, m, &bb,
|
||||
switch (moffset(ms, m, &bb, offset,
|
||||
&ms->c.li[cont_level].off)) {
|
||||
case -1:
|
||||
case 0:
|
||||
|
@ -841,7 +841,7 @@ mprint(struct magic_set *ms, struct magic *m)
|
|||
|
||||
file_private int
|
||||
moffset(struct magic_set *ms, struct magic *m, const struct buffer *b,
|
||||
int32_t *op)
|
||||
size_t offset, int32_t *op)
|
||||
{
|
||||
size_t nbytes = b->flen;
|
||||
int32_t o;
|
||||
|
@ -938,17 +938,17 @@ moffset(struct magic_set *ms, struct magic *m, const struct buffer *b,
|
|||
|
||||
case FILE_REGEX:
|
||||
if ((m->str_flags & REGEX_OFFSET_START) != 0)
|
||||
o = CAST(int32_t, ms->search.offset);
|
||||
o = CAST(int32_t, ms->search.offset - offset);
|
||||
else
|
||||
o = CAST(int32_t,
|
||||
(ms->search.offset + ms->search.rm_len));
|
||||
(ms->search.offset + ms->search.rm_len - offset));
|
||||
break;
|
||||
|
||||
case FILE_SEARCH:
|
||||
if ((m->str_flags & REGEX_OFFSET_START) != 0)
|
||||
o = CAST(int32_t, ms->search.offset);
|
||||
o = CAST(int32_t, ms->search.offset - offset);
|
||||
else
|
||||
o = CAST(int32_t, (ms->search.offset + m->vallen));
|
||||
o = CAST(int32_t, (ms->search.offset + m->vallen - offset));
|
||||
break;
|
||||
|
||||
case FILE_CLEAR:
|
||||
|
@ -1225,14 +1225,14 @@ mconvert(struct magic_set *ms, struct magic *m, int flip)
|
|||
return 1;
|
||||
}
|
||||
case FILE_BESHORT:
|
||||
p->h = CAST(short, BE16(p));
|
||||
p->h = CAST(short, BE16(p->hs));
|
||||
if (cvt_16(p, m) == -1)
|
||||
goto out;
|
||||
return 1;
|
||||
case FILE_BELONG:
|
||||
case FILE_BEDATE:
|
||||
case FILE_BELDATE:
|
||||
p->l = CAST(int32_t, BE32(p));
|
||||
p->l = CAST(int32_t, BE32(p->hl));
|
||||
if (cvt_32(p, m) == -1)
|
||||
goto out;
|
||||
return 1;
|
||||
|
@ -1240,19 +1240,19 @@ mconvert(struct magic_set *ms, struct magic *m, int flip)
|
|||
case FILE_BEQDATE:
|
||||
case FILE_BEQLDATE:
|
||||
case FILE_BEQWDATE:
|
||||
p->q = CAST(uint64_t, BE64(p));
|
||||
p->q = CAST(uint64_t, BE64(p->hq));
|
||||
if (cvt_64(p, m) == -1)
|
||||
goto out;
|
||||
return 1;
|
||||
case FILE_LESHORT:
|
||||
p->h = CAST(short, LE16(p));
|
||||
p->h = CAST(short, LE16(p->hs));
|
||||
if (cvt_16(p, m) == -1)
|
||||
goto out;
|
||||
return 1;
|
||||
case FILE_LELONG:
|
||||
case FILE_LEDATE:
|
||||
case FILE_LELDATE:
|
||||
p->l = CAST(int32_t, LE32(p));
|
||||
p->l = CAST(int32_t, LE32(p->hl));
|
||||
if (cvt_32(p, m) == -1)
|
||||
goto out;
|
||||
return 1;
|
||||
|
@ -1260,14 +1260,14 @@ mconvert(struct magic_set *ms, struct magic *m, int flip)
|
|||
case FILE_LEQDATE:
|
||||
case FILE_LEQLDATE:
|
||||
case FILE_LEQWDATE:
|
||||
p->q = CAST(uint64_t, LE64(p));
|
||||
p->q = CAST(uint64_t, LE64(p->hq));
|
||||
if (cvt_64(p, m) == -1)
|
||||
goto out;
|
||||
return 1;
|
||||
case FILE_MELONG:
|
||||
case FILE_MEDATE:
|
||||
case FILE_MELDATE:
|
||||
p->l = CAST(int32_t, ME32(p));
|
||||
p->l = CAST(int32_t, ME32(p->hl));
|
||||
if (cvt_32(p, m) == -1)
|
||||
goto out;
|
||||
return 1;
|
||||
|
@ -1276,12 +1276,12 @@ mconvert(struct magic_set *ms, struct magic *m, int flip)
|
|||
goto out;
|
||||
return 1;
|
||||
case FILE_BEFLOAT:
|
||||
p->l = BE32(p);
|
||||
p->l = BE32(p->hl);
|
||||
if (cvt_float(p, m) == -1)
|
||||
goto out;
|
||||
return 1;
|
||||
case FILE_LEFLOAT:
|
||||
p->l = LE32(p);
|
||||
p->l = LE32(p->hl);
|
||||
if (cvt_float(p, m) == -1)
|
||||
goto out;
|
||||
return 1;
|
||||
|
@ -1290,12 +1290,12 @@ mconvert(struct magic_set *ms, struct magic *m, int flip)
|
|||
goto out;
|
||||
return 1;
|
||||
case FILE_BEDOUBLE:
|
||||
p->q = BE64(p);
|
||||
p->q = BE64(p->hq);
|
||||
if (cvt_double(p, m) == -1)
|
||||
goto out;
|
||||
return 1;
|
||||
case FILE_LEDOUBLE:
|
||||
p->q = LE64(p);
|
||||
p->q = LE64(p->hq);
|
||||
if (cvt_double(p, m) == -1)
|
||||
goto out;
|
||||
return 1;
|
||||
|
@ -1425,6 +1425,7 @@ mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir,
|
|||
}
|
||||
}
|
||||
*edst = '\0';
|
||||
*dst = '\0';
|
||||
return 0;
|
||||
}
|
||||
case FILE_STRING: /* XXX - these two should not need */
|
||||
|
@ -1619,7 +1620,6 @@ mget(struct magic_set *ms, struct magic *m, const struct buffer *b,
|
|||
}
|
||||
|
||||
|
||||
|
||||
if (mcopy(ms, p, m->type, m->flag & INDIR, s,
|
||||
CAST(uint32_t, offset + o), CAST(uint32_t, nbytes), m) == -1)
|
||||
return -1;
|
||||
|
@ -1641,61 +1641,65 @@ mget(struct magic_set *ms, struct magic *m, const struct buffer *b,
|
|||
intmax_t off = m->in_offset;
|
||||
const int sgn = m->in_op & FILE_OPSIGNED;
|
||||
if (m->in_op & FILE_OPINDIRECT) {
|
||||
const union VALUETYPE *q = CAST(const union VALUETYPE *,
|
||||
RCAST(const void *, s + offset + off));
|
||||
|
||||
uint8_t *hb = CCAST(uint8_t *, s + offset + off);
|
||||
uint16_t hs;
|
||||
uint32_t hl;
|
||||
int op;
|
||||
switch (op = cvt_flip(m->in_type, flip)) {
|
||||
case FILE_BYTE:
|
||||
if (OFFSET_OOB(nbytes, offset + off, 1))
|
||||
return 0;
|
||||
off = SEXT(sgn,8,q->b);
|
||||
off = SEXT(sgn,8,hb[0]);
|
||||
break;
|
||||
case FILE_SHORT:
|
||||
if (OFFSET_OOB(nbytes, offset + off, 2))
|
||||
return 0;
|
||||
off = SEXT(sgn,16,q->h);
|
||||
memcpy(&hs, hb, sizeof(hs));
|
||||
off = SEXT(sgn,16,hs);
|
||||
break;
|
||||
case FILE_BESHORT:
|
||||
if (OFFSET_OOB(nbytes, offset + off, 2))
|
||||
return 0;
|
||||
off = SEXT(sgn,16,BE16(q));
|
||||
off = SEXT(sgn,16,BE16(hb));
|
||||
break;
|
||||
case FILE_LESHORT:
|
||||
if (OFFSET_OOB(nbytes, offset + off, 2))
|
||||
return 0;
|
||||
off = SEXT(sgn,16,LE16(q));
|
||||
off = SEXT(sgn,16,LE16(hb));
|
||||
break;
|
||||
case FILE_LONG:
|
||||
if (OFFSET_OOB(nbytes, offset + off, 4))
|
||||
return 0;
|
||||
off = SEXT(sgn,32,q->l);
|
||||
memcpy(&hl, hb, sizeof(hl));
|
||||
off = SEXT(sgn,32,hl);
|
||||
break;
|
||||
case FILE_BELONG:
|
||||
case FILE_BEID3:
|
||||
if (OFFSET_OOB(nbytes, offset + off, 4))
|
||||
return 0;
|
||||
off = SEXT(sgn,32,BE32(q));
|
||||
off = SEXT(sgn,32,BE32(hb));
|
||||
break;
|
||||
case FILE_LEID3:
|
||||
case FILE_LELONG:
|
||||
if (OFFSET_OOB(nbytes, offset + off, 4))
|
||||
return 0;
|
||||
off = SEXT(sgn,32,LE32(q));
|
||||
off = SEXT(sgn,32,LE32(hb));
|
||||
break;
|
||||
case FILE_MELONG:
|
||||
if (OFFSET_OOB(nbytes, offset + off, 4))
|
||||
return 0;
|
||||
off = SEXT(sgn,32,ME32(q));
|
||||
off = SEXT(sgn,32,ME32(hb));
|
||||
break;
|
||||
case FILE_BEQUAD:
|
||||
if (OFFSET_OOB(nbytes, offset + off, 8))
|
||||
return 0;
|
||||
off = SEXT(sgn,64,BE64(q));
|
||||
off = SEXT(sgn,64,BE64(hb));
|
||||
break;
|
||||
case FILE_LEQUAD:
|
||||
if (OFFSET_OOB(nbytes, offset + off, 8))
|
||||
return 0;
|
||||
off = SEXT(sgn,64,LE64(q));
|
||||
off = SEXT(sgn,64,LE64(hb));
|
||||
break;
|
||||
case FILE_OCTAL:
|
||||
if (OFFSET_OOB(nbytes, offset, m->vallen))
|
||||
|
@ -1720,13 +1724,13 @@ mget(struct magic_set *ms, struct magic *m, const struct buffer *b,
|
|||
case FILE_BESHORT:
|
||||
if (OFFSET_OOB(nbytes, offset, 2))
|
||||
return 0;
|
||||
if (do_ops(ms, m, &offset, SEXT(sgn,16,BE16(p)), off))
|
||||
if (do_ops(ms, m, &offset, SEXT(sgn,16,BE16(p->hs)), off))
|
||||
return 0;
|
||||
break;
|
||||
case FILE_LESHORT:
|
||||
if (OFFSET_OOB(nbytes, offset, 2))
|
||||
return 0;
|
||||
if (do_ops(ms, m, &offset, SEXT(sgn,16,LE16(p)), off))
|
||||
if (do_ops(ms, m, &offset, SEXT(sgn,16,LE16(p->hs)), off))
|
||||
return 0;
|
||||
break;
|
||||
case FILE_SHORT:
|
||||
|
@ -1739,7 +1743,7 @@ mget(struct magic_set *ms, struct magic *m, const struct buffer *b,
|
|||
case FILE_BEID3:
|
||||
if (OFFSET_OOB(nbytes, offset, 4))
|
||||
return 0;
|
||||
lhs = BE32(p);
|
||||
lhs = BE32(p->hl);
|
||||
if (in_type == FILE_BEID3)
|
||||
lhs = cvt_id3(ms, CAST(uint32_t, lhs));
|
||||
if (do_ops(ms, m, &offset, SEXT(sgn,32,lhs), off))
|
||||
|
@ -1749,7 +1753,7 @@ mget(struct magic_set *ms, struct magic *m, const struct buffer *b,
|
|||
case FILE_LEID3:
|
||||
if (OFFSET_OOB(nbytes, offset, 4))
|
||||
return 0;
|
||||
lhs = LE32(p);
|
||||
lhs = LE32(p->hl);
|
||||
if (in_type == FILE_LEID3)
|
||||
lhs = cvt_id3(ms, CAST(uint32_t, lhs));
|
||||
if (do_ops(ms, m, &offset, SEXT(sgn,32,lhs), off))
|
||||
|
@ -1758,7 +1762,7 @@ mget(struct magic_set *ms, struct magic *m, const struct buffer *b,
|
|||
case FILE_MELONG:
|
||||
if (OFFSET_OOB(nbytes, offset, 4))
|
||||
return 0;
|
||||
if (do_ops(ms, m, &offset, SEXT(sgn,32,ME32(p)), off))
|
||||
if (do_ops(ms, m, &offset, SEXT(sgn,32,ME32(p->hl)), off))
|
||||
return 0;
|
||||
break;
|
||||
case FILE_LONG:
|
||||
|
@ -1770,13 +1774,13 @@ mget(struct magic_set *ms, struct magic *m, const struct buffer *b,
|
|||
case FILE_LEQUAD:
|
||||
if (OFFSET_OOB(nbytes, offset, 8))
|
||||
return 0;
|
||||
if (do_ops(ms, m, &offset, SEXT(sgn,64,LE64(p)), off))
|
||||
if (do_ops(ms, m, &offset, SEXT(sgn,64,LE64(p->hq)), off))
|
||||
return 0;
|
||||
break;
|
||||
case FILE_BEQUAD:
|
||||
if (OFFSET_OOB(nbytes, offset, 8))
|
||||
return 0;
|
||||
if (do_ops(ms, m, &offset, SEXT(sgn,64,BE64(p)), off))
|
||||
if (do_ops(ms, m, &offset, SEXT(sgn,64,BE64(p->hq)), off))
|
||||
return 0;
|
||||
break;
|
||||
case FILE_OCTAL:
|
||||
|
|
|
@ -1,213 +1,20 @@
|
|||
diff -ur Magdir.orig/javascript Magdir/javascript
|
||||
--- Magdir.orig/javascript 2024-12-04 21:21:54.168928738 +0100
|
||||
+++ Magdir/javascript 2024-12-04 21:21:56.652262003 +0100
|
||||
@@ -17,37 +17,38 @@
|
||||
!:mime application/javascript
|
||||
|
||||
# JavaScript
|
||||
-# The strength is increased to beat the C++ & HTML rules
|
||||
+# The strength is increased to beat the C++ but lose to HTML rules,
|
||||
+# because javascript is embedded in hmtl files typically
|
||||
0 search "use\x20strict" JavaScript source
|
||||
-!:strength +30
|
||||
+!:strength +20
|
||||
!:mime application/javascript
|
||||
!:ext js
|
||||
0 search 'use\x20strict' JavaScript source
|
||||
-!:strength +30
|
||||
+!:strength +20
|
||||
!:mime application/javascript
|
||||
!:ext js
|
||||
0 regex module(\\.|\\[["'])exports.*= JavaScript source
|
||||
-!:strength +30
|
||||
+!:strength +20
|
||||
!:mime application/javascript
|
||||
!:ext js
|
||||
0 regex \^(const|var|let).*=.*require\\( JavaScript source
|
||||
-!:strength +30
|
||||
+!:strength +20
|
||||
!:mime application/javascript
|
||||
!:ext js
|
||||
0 regex \^export\x20(function|class|default|const|var|let|async)\x20 JavaScript source
|
||||
-!:strength +30
|
||||
+!:strength +20
|
||||
!:mime application/javascript
|
||||
!:ext js
|
||||
0 regex \\((async\x20)?function[(\x20] JavaScript source
|
||||
-!:strength +30
|
||||
+!:strength +20
|
||||
!:mime application/javascript
|
||||
!:ext js
|
||||
0 regex \^(import|export).*\x20from\x20 JavaScript source
|
||||
-!:strength +30
|
||||
+!:strength +20
|
||||
!:mime application/javascript
|
||||
!:ext js
|
||||
0 regex \^(import|export)\x20["']\\./ JavaScript source
|
||||
-!:strength +30
|
||||
+!:strength +20
|
||||
!:mime application/javascript
|
||||
!:ext js
|
||||
0 regex \^require\\(["'] JavaScript source
|
||||
@@ -55,13 +56,13 @@
|
||||
!:mime application/javascript
|
||||
!:ext js
|
||||
0 regex typeof.*[!=]== JavaScript source
|
||||
-!:strength +30
|
||||
+!:strength +20
|
||||
!:mime application/javascript
|
||||
!:ext js
|
||||
|
||||
# React Native minified JavaScript
|
||||
0 search/128 __BUNDLE_START_TIME__= React Native minified JavaScript
|
||||
-!:strength +30
|
||||
+!:strength +20
|
||||
!:mime application/javascript
|
||||
!:ext bundle/jsbundle
|
||||
|
||||
diff -ur Magdir.orig/rpm Magdir/rpm
|
||||
--- Magdir.orig/rpm 2024-12-04 21:21:54.175595405 +0100
|
||||
+++ Magdir/rpm 2024-12-04 21:21:56.652262003 +0100
|
||||
@@ -29,6 +29,7 @@
|
||||
>>8 beshort 17 SuperH
|
||||
>>8 beshort 18 Xtensa
|
||||
--- Magdir.orig/rpm 2025-02-09 12:44:15.956602145 +0100
|
||||
+++ Magdir/rpm 2025-02-09 12:45:16.560624196 +0100
|
||||
@@ -34,6 +34,7 @@
|
||||
>>8 beshort 22 RISC-V64
|
||||
>>8 beshort 23 LoongArch64
|
||||
>>8 beshort 255 noarch
|
||||
+>>10 string x %s
|
||||
|
||||
#delta RPM Daniel Novotny (dnovotny@redhat.com)
|
||||
0 string drpm Delta RPM
|
||||
diff -ur Magdir.orig/securitycerts Magdir/securitycerts
|
||||
--- Magdir.orig/securitycerts 2024-12-04 21:21:54.175595405 +0100
|
||||
+++ Magdir/securitycerts 2024-12-04 21:21:56.652262003 +0100
|
||||
--- Magdir.orig/securitycerts 2025-02-09 12:44:15.956628770 +0100
|
||||
+++ Magdir/securitycerts 2025-02-09 12:44:44.077144142 +0100
|
||||
@@ -4,3 +4,5 @@
|
||||
0 search/1 -----BEGIN\ CERTIFICATE------ RFC1421 Security Certificate text
|
||||
0 search/1 -----BEGIN\ NEW\ CERTIFICATE RFC1421 Security Certificate Signing Request text
|
||||
0 belong 0xedfeedfe Sun 'jks' Java Keystore File data
|
||||
+
|
||||
+0 string \0volume_key volume_key escrow packet
|
||||
diff -ur Magdir.orig/sgml Magdir/sgml
|
||||
--- Magdir.orig/sgml 2024-12-04 21:21:54.175595405 +0100
|
||||
+++ Magdir/sgml 2024-12-04 21:21:56.652262003 +0100
|
||||
@@ -1,16 +1,17 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
-# $File: sgml,v 1.48 2023/01/18 16:10:21 christos Exp $
|
||||
+# $File: sgml,v 1.49 2023/08/05 14:34:47 christos Exp $
|
||||
# Type: SVG Vectorial Graphics
|
||||
# From: Noel Torres <tecnico@ejerciciosresueltos.com>
|
||||
-0 string \<?xml\ version=
|
||||
+0 string/bt \<?xml\ version=
|
||||
>14 regex ['"\ \t]*[0-9.]+['"\ \t]*
|
||||
>>19 search/4096 \<svg SVG Scalable Vector Graphics image
|
||||
+!:strength +50
|
||||
!:mime image/svg+xml
|
||||
!:ext svg
|
||||
>>19 search/4096 \<gnc-v2 GnuCash file
|
||||
!:mime application/x-gnucash
|
||||
-0 string \<svg SVG Scalable Vector Graphics image
|
||||
+0 string/bt \<svg SVG Scalable Vector Graphics image
|
||||
!:mime image/svg+xml
|
||||
!:ext svg
|
||||
|
||||
@@ -53,11 +54,14 @@
|
||||
# avoid misdetection as JavaScript
|
||||
0 string/cWt \<!doctype\ html HTML document text
|
||||
!:mime text/html
|
||||
+!:strength + 30
|
||||
0 string/ct \<html> HTML document text
|
||||
!:mime text/html
|
||||
+!:strength + 30
|
||||
0 string/ct \<!--
|
||||
>&0 search/4096/cWt \<!doctype\ html HTML document text
|
||||
!:mime text/html
|
||||
+!:strength + 30
|
||||
>&0 search/4096/ct \<html> HTML document text
|
||||
!:mime text/html
|
||||
|
||||
@@ -65,69 +69,61 @@
|
||||
# https://www.w3.org/TR/SVG/single-page.html
|
||||
0 search/4096/cWbt \<!doctype\ svg SVG XML document
|
||||
!:mime image/svg+xml
|
||||
-!:strength + 15
|
||||
+!:strength + 30
|
||||
|
||||
0 search/4096/cwt \<head\> HTML document text
|
||||
!:mime text/html
|
||||
-!:strength + 15
|
||||
+!:strength + 30
|
||||
0 search/4096/cWt \<head\ HTML document text
|
||||
!:mime text/html
|
||||
-!:strength + 15
|
||||
+!:strength + 30
|
||||
0 search/4096/cwt \<title\> HTML document text
|
||||
!:mime text/html
|
||||
-!:strength + 15
|
||||
+!:strength + 30
|
||||
0 search/4096/cWt \<title\ HTML document text
|
||||
!:mime text/html
|
||||
-!:strength + 15
|
||||
+!:strength + 30
|
||||
0 search/4096/cwt \<html\> HTML document text
|
||||
!:mime text/html
|
||||
-!:strength + 15
|
||||
+!:strength + 30
|
||||
0 search/4096/cWt \<html\ HTML document text
|
||||
!:mime text/html
|
||||
-!:strength + 15
|
||||
+!:strength + 30
|
||||
0 search/4096/cwt \<script\> HTML document text
|
||||
!:mime text/html
|
||||
-!:strength + 15
|
||||
+!:strength + 30
|
||||
0 search/4096/cWt \<script\ HTML document text
|
||||
!:mime text/html
|
||||
-!:strength + 15
|
||||
+!:strength + 30
|
||||
0 search/4096/cwt \<style\> HTML document text
|
||||
!:mime text/html
|
||||
-!:strength + 15
|
||||
+!:strength + 30
|
||||
0 search/4096/cWt \<style\ HTML document text
|
||||
!:mime text/html
|
||||
-!:strength + 15
|
||||
+!:strength + 30
|
||||
0 search/4096/cwt \<table\> HTML document text
|
||||
!:mime text/html
|
||||
-!:strength + 15
|
||||
+!:strength + 30
|
||||
0 search/4096/cWt \<table\ HTML document text
|
||||
!:mime text/html
|
||||
-!:strength + 15
|
||||
+!:strength + 30
|
||||
|
||||
0 search/4096/cwt \<a\ href= HTML document text
|
||||
!:mime text/html
|
||||
-!:strength + 15
|
||||
+!:strength + 30
|
||||
|
||||
# Extensible markup language (XML), a subset of SGML
|
||||
# from Marc Prud'hommeaux (marc@apocalypse.org)
|
||||
0 search/1/cwt \<?xml XML document text
|
||||
!:mime text/xml
|
||||
-!:strength + 15
|
||||
-0 string/t \<?xml\ version\ " XML
|
||||
-!:mime text/xml
|
||||
-!:strength + 15
|
||||
+!:strength + 30
|
||||
0 string/t \<?xml\ version=" XML
|
||||
!:mime text/xml
|
||||
-!:strength + 15
|
||||
->15 string/t >\0 %.3s document text
|
||||
->>23 search/1 \<xsl:stylesheet (XSL stylesheet)
|
||||
->>24 search/1 \<xsl:stylesheet (XSL stylesheet)
|
||||
-0 string/t \<?xml\ version=' XML
|
||||
-!:mime text/xml
|
||||
-!:strength + 15
|
||||
+!:strength + 30
|
||||
>15 string/t >\0 %.3s document text
|
||||
>>23 search/1 \<xsl:stylesheet (XSL stylesheet)
|
||||
>>24 search/1 \<xsl:stylesheet (XSL stylesheet)
|
||||
+
|
||||
0 search/1/wt \<?XML broken XML document text
|
||||
!:mime text/xml
|
||||
!:strength - 10
|
||||
|
|
|
@ -1 +1 @@
|
|||
UF2 firmware image, family ESP32-S2, address 00000000, 4829 total blocks
|
||||
UF2 firmware image, family ESP32-S2, base address 00000000, 4829 total blocks
|
Loading…
Add table
Add a link
Reference in a new issue