-See COPYING.
\ No newline at end of file
+See COPYING.
-$File: LEGAL.NOTICE,v 1.15 2006/05/03 18:48:33 christos Exp $
+$File: COPYING,v 1.2 2018/09/09 20:33:28 christos Exp $
Copyright (c) Ian F. Darwin 1986, 1987, 1989, 1990, 1991, 1992, 1994, 1995.
Software written by Ian F. Darwin and others;
maintained 1994- Christos Zoulas.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
-
+
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2018-08-20 18:40 Christos Zoulas <christos@zoulas.com>
-
+
* PR/30: Allow all parameter values to be set (don't treat 0 specially)
* handle default annotations on the softmagic match instead at the
end.
* release 5.33
-2018-02-24 14:50 Christos Zoulas <christos@zoulas.com>
+2018-02-24 14:50 Christos Zoulas <christos@zoulas.com>
* extend the support for ${x?:} expansions for magic descriptions
-2018-02-21 16:25 Christos Zoulas <christos@zoulas.com>
+2018-02-21 16:25 Christos Zoulas <christos@zoulas.com>
* add support for ${x?:} in mime types to handle
pie binaries.
* Add missing overflow check in der magic (Jonas Wagner)
2016-10-25 10:40 Christos Zoulas <christos@zoulas.com>
-
+
* release 5.29
2016-10-24 11:20 Christos Zoulas <christos@zoulas.com>
- set offset to 0 on failure.
2016-05-13 12:00 Christos Zoulas <christos@zoulas.com>
-
+
* release 5.27
2016-04-18 9:35 Christos Zoulas <christos@zoulas.com>
-
+
* Errors comparing DER entries or computing offsets
are just indications of malformed non-DER files.
Don't print them.
* Put new bytes constant in the right file (not the generated one)
2016-04-16 18:34 Christos Zoulas <christos@zoulas.com>
-
+
* release 5.26
2016-03-31 13:50 Christos Zoulas <christos@zoulas.com>
* PR/492: compression forking was broken with magic_buffer.
2015-09-16 9:50 Christos Zoulas <christos@zoulas.com>
-
+
* release 5.25
2015-09-11 13:25 Christos Zoulas <christos@zoulas.com>
* release 5.23
2015-06-09 16:10 Christos Zoulas <christos@zoulas.com>
-
+
* Fix issue with regex range for magic with offset
* Always return true from mget with USE (success to mget not match
indication). Fixes mime evaluation after USE magic
* add indirect relative for TIFF/Exif
2014-12-16 18:10 Christos Zoulas <christos@zoulas.com>
-
+
* restructure elf note printing to avoid repeated messages
* add note limit, suggested by Alexander Cherepanov
2014-12-16 16:53 Christos Zoulas <christos@zoulas.com>
-
+
* Bail out on partial pread()'s (Alexander Cherepanov)
* Fix incorrect bounds check in file_printable (Alexander Cherepanov)
more places for safety
* in ELF, instead of "(uses dynamic libraries)" when PT_INTERP
is present print the interpreter name.
-
+
2014-12-10 20:01 Christos Zoulas <christos@zoulas.com>
* release 5.21
on a byte by byte basis, so that we don't get issues with
locale's trying to interpret random byte streams as UTF-8 and
having printf error out with EILSEQ.
-
+
2014-10-17 11:48 Christos Zoulas <christos@zoulas.com>
* fix bounds in note reading (Francisco Alonso / Red Hat)
* release 5.19
2014-06-09 9:04 Christos Zoulas <christos@zoulas.com>
-
+
* Misc buffer overruns and missing buffer size tests in cdf parsing
(Francisco Alonso, Jan Kaluza)
2014-05-04 14:55 Christos Zoulas <christos@zoulas.com>
- * PR/351: Fix compilation of empty files
+ * PR/351: Fix compilation of empty files
2014-04-30 17:39 Christos Zoulas <christos@zoulas.com>
* Don't treat magic as an error if offset was past EOF (Christoph Biedl)
2013-05-28 17:25 Christos Zoulas <christos@zoulas.com>
-
+
* Fix spacing issues in softmagic and elf (Jan Kaluza)
2013-05-02 18:00 Christos Zoulas <christos@zoulas.com>
* Make getline public so that file can link against it.
Perhaps it is better to rename it, or hide it differently.
Fixes builds on platforms that do not provide it.
-
+
2013-01-07 16:30 Christos Zoulas <christos@zoulas.com>
* Add SuS d{,1,2,4,8}, u{,1,2,4,8} and document
(Cheng Renquan)
2009-05-08 13:40 Christos Zoulas <christos@zoulas.com>
-
+
* lint fixes and more from NetBSD
2009-05-06 10:25 Christos Zoulas <christos@zoulas.com>
2009-03-27 18:43 Christos Zoulas <christos@zoulas.com>
- * don't print \012- separators in the same magic entry
+ * don't print \012- separators in the same magic entry
if it consists of multiple magic printing lines.
2009-03-23 10:20 Christos Zoulas <christos@zoulas.com>
-See ChangeLog.
\ No newline at end of file
+See ChangeLog.
## README for file(1) Command ##
- @(#) $File: README,v 1.55 2018/08/18 11:45:05 christos Exp $
+ @(#) $File: README,v 1.56 2018/09/09 20:33:28 christos Exp $
Mailing List: file@astron.com
Mailing List archives: http://mailman.astron.com/pipermail/file/
are in reasonable circulation. Send your magic numbers,
in magic(5) format please, to the maintainer, Christos Zoulas.
-COPYING - read this first.
-README - read this second (you are currently reading this file).
+COPYING - read this first.
+README - read this second (you are currently reading this file).
INSTALL - read on how to install
-src/apprentice.c - parses /etc/magic to learn magic
-src/apptype.c - used for OS/2 specific application type magic
-src/ascmagic.c - third & last set of tests, based on hardwired assumptions.
-src/asctime_r.c - replacement for OS's that don't have it.
-src/asprintf.c - replacement for OS's that don't have it.
-src/asctime_r.c - replacement for OS's that don't have it.
-src/asprintf.c - replacement for OS's that don't have it.
+src/apprentice.c - parses /etc/magic to learn magic
+src/apptype.c - used for OS/2 specific application type magic
+src/ascmagic.c - third & last set of tests, based on hardwired assumptions.
+src/asctime_r.c - replacement for OS's that don't have it.
+src/asprintf.c - replacement for OS's that don't have it.
+src/asctime_r.c - replacement for OS's that don't have it.
+src/asprintf.c - replacement for OS's that don't have it.
src/buffer.c - buffer handling functions.
-src/cdf.[ch] - parser for Microsoft Compound Document Files
-src/cdf_time.c - time converter for CDF.
-src/compress.c - handles decompressing files to look inside.
-src/ctime_r.c - replacement for OS's that don't have it.
+src/cdf.[ch] - parser for Microsoft Compound Document Files
+src/cdf_time.c - time converter for CDF.
+src/compress.c - handles decompressing files to look inside.
+src/ctime_r.c - replacement for OS's that don't have it.
src/der.[ch] - parser for Distinguished Encoding Rules
src/dprintf.c - replacement for OS's that don't have it.
src/elfclass.h - common code for elf 32/64.
-src/encoding.c - handles unicode encodings
-src/file.c - the main program
-src/file.h - header file
+src/encoding.c - handles unicode encodings
+src/file.c - the main program
+src/file.h - header file
src/file_opts.h - list of options
-src/fmtcheck.c - replacement for OS's that don't have it.
-src/fsmagic.c - first set of tests the program runs, based on filesystem info
-src/funcs.c - utilility functions
-src/getline.c - replacement for OS's that don't have it.
-src/getopt_long.c - replacement for OS's that don't have it.
-src/gmtime_r.c - replacement for OS's that don't have it.
+src/fmtcheck.c - replacement for OS's that don't have it.
+src/fsmagic.c - first set of tests the program runs, based on filesystem info
+src/funcs.c - utilility functions
+src/getline.c - replacement for OS's that don't have it.
+src/getopt_long.c - replacement for OS's that don't have it.
+src/gmtime_r.c - replacement for OS's that don't have it.
src/is_json.c - knows about JavaScript Object Notation format (RFC 8259).
-src/is_tar.c, tar.h - knows about Tape ARchive format (courtesy John Gilmore).
-src/localtime_r.c - replacement for OS's that don't have it.
+src/is_tar.c, tar.h - knows about Tape ARchive format (courtesy John Gilmore).
+src/localtime_r.c - replacement for OS's that don't have it.
src/magic.h.in - source file for magic.h
-src/mygetopt.h - replacement for OS's that don't have it.
-src/magic.c - the libmagic api
-src/names.h - header file for ascmagic.c
-src/pread.c - replacement for OS's that don't have it.
-src/print.c - print results, errors, warnings.
+src/mygetopt.h - replacement for OS's that don't have it.
+src/magic.c - the libmagic api
+src/names.h - header file for ascmagic.c
+src/pread.c - replacement for OS's that don't have it.
+src/print.c - print results, errors, warnings.
src/readcdf.c - CDF wrapper.
-src/readelf.[ch] - Stand-alone elf parsing code.
-src/softmagic.c - 2nd set of tests, based on /etc/magic
-src/mygetopt.h - replacement for OS's that don't have it.
-src/strcasestr.c - replacement for OS's that don't have it.
-src/strlcat.c - replacement for OS's that don't have it.
-src/strlcpy.c - replacement for OS's that don't have it.
-src/strndup.c - replacement for OS's that don't have it.
+src/readelf.[ch] - Stand-alone elf parsing code.
+src/softmagic.c - 2nd set of tests, based on /etc/magic
+src/mygetopt.h - replacement for OS's that don't have it.
+src/strcasestr.c - replacement for OS's that don't have it.
+src/strlcat.c - replacement for OS's that don't have it.
+src/strlcpy.c - replacement for OS's that don't have it.
+src/strndup.c - replacement for OS's that don't have it.
src/tar.h - tar file definitions
-src/vasprintf.c - for systems that don't have it.
-doc/file.man - man page for the command
+src/vasprintf.c - for systems that don't have it.
+doc/file.man - man page for the command
doc/magic.man - man page for the magic file, courtesy Guy Harris.
Install as magic.4 on USG and magic.5 on V7 or Berkeley; cf Makefile.
-.\" $File: libmagic.man,v 1.43 2018/08/18 14:44:48 christos Exp $
+.\" $File: libmagic.man,v 1.44 2018/09/09 20:33:28 christos Exp $
.\"
.\" Copyright (c) Christos Zoulas 2003, 2018.
.\" All Rights Reserved.
.Xr file __CSECTION__ ,
.Xr magic __FSECTION__
.Sh BUGS
-The results from
+The results from
.Fn magic_buffer
and
.Fn magic_file
#
-# $File: Makefile.am,v 1.134 2018/08/02 06:33:05 christos Exp $
+# $File: Makefile.am,v 1.135 2018/09/09 20:33:28 christos Exp $
#
MAGIC_FRAGMENT_BASE = Magdir
MAGIC_DIR = $(top_srcdir)/magic
$(MAGIC_FRAGMENT_DIR)/zfs \
$(MAGIC_FRAGMENT_DIR)/zilog \
$(MAGIC_FRAGMENT_DIR)/zip \
-$(MAGIC_FRAGMENT_DIR)/zyxel
+$(MAGIC_FRAGMENT_DIR)/zyxel
MAGIC = magic.mgc
CLEANFILES = ${MAGIC} $(MAGIC_FRAGMENT_DIR)/Localstuff
if MINGW
MINGWLIBS = -lgnurx -lshlwapi
else
-MINGWLIBS =
+MINGWLIBS =
endif
libmagic_la_LIBADD = $(LTLIBOBJS) $(MINGWLIBS)
-# Makefile for file(1) cmd.
+# Makefile for file(1) cmd.
# Copyright (c) Ian F. Darwin 86/09/01 - see LEGAL.NOTICE.
-# @(#)$Id: Makefile.std,v 1.19 2014-06-03 19:17:27 christos Exp $
+# @(#)$Id: Makefile.std,v 1.20 2018/09/09 20:33:28 christos Exp $
#
# This software is not subject to any license of the American Telephone
# and Telegraph Company or of the Regents of the University of California.
OFILE = /usr/bin/file # old or distributed version, for comparison
# Where new binary lives; typically /usr/local (BSD), /usr/lbin (USG).
BINDIR = /usr/local/bin
-# For installing our man pages;
+# For installing our man pages;
# MANCxxx is manual section for Commands, MANFxxx is section for file formats.
# MANxDIR is directory names; MANxEXT is the filename extension. Usual values:
# Variable V7 4BSD Sys V
* Copyright (c) Ian F. Darwin 1986-1995.
* Software written by Ian F. Darwin and others;
* maintained 1995-present by Christos Zoulas and others.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: apprentice.c,v 1.278 2018/09/01 15:52:02 christos Exp $")
+FILE_RCSID("@(#)$File: apprentice.c,v 1.279 2018/09/09 20:33:28 christos Exp $")
#endif /* lint */
#include "magic.h"
#define MAP_TYPE_MMAP 2
struct magic_entry {
- struct magic *mp;
+ struct magic *mp;
uint32_t cont_count;
uint32_t max_count;
};
private size_t apprentice_magic_strength(const struct magic *);
private int apprentice_sort(const void *, const void *);
private void apprentice_list(struct mlist *, int );
-private struct magic_map *apprentice_load(struct magic_set *,
+private struct magic_map *apprentice_load(struct magic_set *,
const char *, int);
private struct mlist *mlist_alloc(void);
private void mlist_free(struct mlist *);
return val;
}
-/*
+/*
* Sort callback for sorting entries by "strength" (basically length)
*/
private int
return 1;
}
-/*
+/*
* Shows sorted patterns list in the order which is used for the matching
*/
private void
mstart->flag |= BINTEST;
if (mstart->str_flags & STRING_TEXTTEST)
mstart->flag |= TEXTTEST;
-
+
if (mstart->flag & (TEXTTEST|BINTEST))
break;
file_magwarn(ms,
"level 0 \"default\" did not sort last");
}
- return;
+ return;
}
}
}
*/
while (*l == '>') {
++l; /* step over */
- cont_level++;
+ cont_level++;
}
#ifdef ENABLE_CONDITIONALS
if (cont_level == 0 || cont_level > last_cont_level)
}
l = t;
}
- if (*l++ != ')' ||
+ if (*l++ != ')' ||
((m->in_op & FILE_OPINDIRECT) && *l++ != ')')) {
if (ms->flags & MAGIC_CHECK)
file_magwarn(ms,
/*
* Try it as a keyword type prefixed by "u"; match what
* follows the "u". If that fails, try it as an SUS
- * integer type.
+ * integer type.
*/
m->type = get_type(type_tbl, l + 1, &l);
if (m->type == FILE_INVALID) {
/* Not found - try it as a special keyword. */
m->type = get_type(special_tbl, l, &l);
}
-
+
if (m->type == FILE_INVALID) {
if (ms->flags & MAGIC_CHECK)
file_magwarn(ms, "type `%s' invalid", l);
* anything if mask = 0 (unless you have a better idea)
*/
EATAB;
-
+
switch (*l) {
case '>':
case '<':
break;
default:
m->reln = '='; /* the default relation */
- if (*l == 'x' && ((isascii((unsigned char)l[1]) &&
+ if (*l == 'x' && ((isascii((unsigned char)l[1]) &&
isspace((unsigned char)l[1])) || !l[1])) {
m->reln = *l;
++l;
/*
* TODO finish this macro and start using it!
- * #define offsetcheck {if (offset > ms->bytes_max -1)
+ * #define offsetcheck {if (offset > ms->bytes_max -1)
* magwarn("offset too big"); }
*/
file_magwarn(ms, "Current entry already has a %s type "
"`%.*s', new type `%s'", name, (int)len, buf, l);
return -1;
- }
+ }
if (*m->desc == '\0') {
file_magwarn(ms, "Current entry does not yet have a "
if (*ptr++ != 'l')
goto invalid;
}
-
+
switch (*ptr++) {
#ifdef STRICT_FORMAT /* "long" formats are int formats for us */
/* so don't accept the 'l' modifier */
default:
goto invalid;
}
-
+
/*
* Don't accept h and hh modifiers. They make writing
* magic entries more complicated, for very little benefit
default:
goto invalid;
}
-
+
case FILE_FMT_FLOAT:
case FILE_FMT_DOUBLE:
if (*ptr == '-')
case 'g':
case 'G':
return 0;
-
+
default:
goto invalid;
}
-
+
case FILE_FMT_STR:
if (*ptr == '-')
while (isdigit((unsigned char )*ptr))
ptr++;
}
-
+
switch (*ptr++) {
case 's':
return 0;
default:
goto invalid;
}
-
+
default:
/* internal error */
abort();
*estr = "too long";
return -1;
}
-
+
/*
* Check that the optional printf format in description matches
* the type of the magic.
if (m->type >= file_nformats) {
file_magwarn(ms, "Internal error inconsistency between "
- "m->type and format strings");
+ "m->type and format strings");
return -1;
}
if (file_formats[m->type] == FILE_FMT_NONE) {
file_names[m->type], m->desc);
return -1;
}
-
+
for (; *ptr; ptr++) {
if (*ptr == '%') {
file_magwarn(ms,
return 0;
}
-/*
- * Read a numeric value from a pointer, into the value union of a magic
- * pointer, according to the magic type. Update the string pointer to point
+/*
+ * Read a numeric value from a pointer, into the value union of a magic
+ * pointer, according to the magic type. Update the string pointer to point
* just after the number read. Return 0 for success, non-zero for failure.
*/
private int
default:
if (warn) {
if (isprint((unsigned char)c)) {
- /* Allow escaping of
+ /* Allow escaping of
* ``relations'' */
if (strchr("<>&^=!", c) == NULL
&& (m->type != FILE_REGEX ||
{
const char *l = *p;
- if (LOWCASE(*l) == 'u')
+ if (LOWCASE(*l) == 'u')
l++;
switch (LOWCASE(*l)) {
dbname = mkdbname(ms, fn, 1);
- if (dbname == NULL)
+ if (dbname == NULL)
goto out;
- if ((fd = open(dbname, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0644)) == -1)
+ if ((fd = open(dbname, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0644)) == -1)
{
file_error(ms, errno, "cannot open `%s'", dbname);
goto out;
swap2(uint16_t sv)
{
uint16_t rv;
- uint8_t *s = (uint8_t *)(void *)&sv;
- uint8_t *d = (uint8_t *)(void *)&rv;
+ uint8_t *s = (uint8_t *)(void *)&sv;
+ uint8_t *d = (uint8_t *)(void *)&rv;
d[0] = s[1];
d[1] = s[0];
return rv;
swap4(uint32_t sv)
{
uint32_t rv;
- uint8_t *s = (uint8_t *)(void *)&sv;
- uint8_t *d = (uint8_t *)(void *)&rv;
+ uint8_t *s = (uint8_t *)(void *)&sv;
+ uint8_t *d = (uint8_t *)(void *)&rv;
d[0] = s[3];
d[1] = s[2];
d[2] = s[1];
swap8(uint64_t sv)
{
uint64_t rv;
- uint8_t *s = (uint8_t *)(void *)&sv;
- uint8_t *d = (uint8_t *)(void *)&rv;
+ uint8_t *s = (uint8_t *)(void *)&sv;
+ uint8_t *d = (uint8_t *)(void *)&rv;
#if 0
d[0] = s[3];
d[1] = s[2];
}
}
-protected size_t
+protected size_t
file_pstring_length_size(const struct magic *m)
{
switch (m->str_flags & PSTRING_LEN) {
/*
* Adapted from: apptype.c, Written by Eberhard Mattes and put into the
* public domain
- *
+ *
* Notes: 1. Qualify the filename so that DosQueryAppType does not do extraneous
* searches.
- *
+ *
* 2. DosQueryAppType will return FAPPTYP_DOS on a file ending with ".com"
* (other than an OS/2 exe or Win exe with this name). Eberhard Mattes
* remarks Tue, 6 Apr 93: Moreover, it reports the type of the (new and very
* bug ridden) Win Emacs as "OS/2 executable".
- *
+ *
* 3. apptype() uses the filename if given, otherwise a tmp file is created with
* the contents of buf. If buf is not the complete file, apptype can
* incorrectly identify the exe type. The "-z" option of "file" is the reason
/*
* amai: Darrel Hankerson did the changes described here.
- *
+ *
* It remains to check the validity of comments (2.) since it's referred to an
* "old" OS/2 version.
- *
+ *
*/
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: apptype.c,v 1.12 2011/08/28 07:03:27 christos Exp $")
+FILE_RCSID("@(#)$File: apptype.c,v 1.14 2018/09/09 20:33:28 christos Exp $")
#endif /* lint */
#include <stdlib.h>
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: ascmagic.c,v 1.98 2017/11/02 20:25:39 christos Exp $")
+FILE_RCSID("@(#)$File: ascmagic.c,v 1.99 2018/09/09 20:33:28 christos Exp $")
#endif /* lint */
#include "magic.h"
}
protected int
-file_ascmagic_with_encoding(struct magic_set *ms,
+file_ascmagic_with_encoding(struct magic_set *ms,
const struct buffer *b, unichar *ubuf, size_t ulen, const char *code,
const char *type, int text)
{
* Copyright (c) Ian F. Darwin 1986-1995.
* Software written by Ian F. Darwin and others;
* maintained 1995-present by Christos Zoulas and others.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: asprintf.c,v 1.3 2009/02/03 20:27:51 christos Exp $")
+FILE_RCSID("@(#)$File: asprintf.c,v 1.5 2018/09/09 20:33:28 christos Exp $")
#endif
int asprintf(char **ptr, const char *fmt, ...)
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: cdf.c,v 1.110 2017/12/19 00:21:21 christos Exp $")
+FILE_RCSID("@(#)$File: cdf.c,v 1.111 2018/09/09 20:33:28 christos Exp $")
#endif
#include <assert.h>
}
static const uint8_t *
-cdf_get_property_info_pos(const cdf_stream_t *sst, const cdf_header_t *h,
+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)
{
size_t tail = (i << 1) + 1;
__LINE__) == -1)
return NULL;
ofs = CDF_GETUINT32(p, tail);
- q = CAST(const uint8_t *, cdf_offset(CAST(const void *, p),
+ q = CAST(const uint8_t *, cdf_offset(CAST(const void *, p),
ofs - 2 * sizeof(uint32_t)));
if (q < p) {
size_t newcount = *maxcount + incr;
if (newcount > CDF_PROP_LIMIT) {
- DPRINTF(("exceeded property limit %zu > %zu\n",
+ DPRINTF(("exceeded property limit %zu > %zu\n",
newcount, CDF_PROP_LIMIT));
goto out;
}
typedef struct {
uint16_t ce_namlen;
uint32_t ce_num;
- uint64_t ce_timestamp;
+ uint64_t ce_timestamp;
uint16_t ce_name[256];
} cdf_catalog_entry_t;
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: cdf_time.c,v 1.16 2017/03/29 15:57:48 christos Exp $")
+FILE_RCSID("@(#)$File: cdf_time.c,v 1.17 2018/09/09 20:33:28 christos Exp $")
#endif
#include <time.h>
for (y = CDF_BASE_YEAR; y < year; y++)
days += isleap(y) + 365;
-
+
return days;
}
return days;
}
-/*
+/*
* Return the 0...11 month number.
*/
static int
* Copyright (c) Ian F. Darwin 1986-1995.
* Software written by Ian F. Darwin and others;
* maintained 1995-present by Christos Zoulas and others.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* compress routines:
* zmagic() - returns 0 if not recognized, uncompresses and prints
* information if recognized
- * uncompress(method, old, n, newch) - uncompress old into new,
+ * uncompress(method, old, n, newch) - uncompress old into new,
* using method, return sizeof new
*/
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: compress.c,v 1.109 2018/08/01 10:11:16 christos Exp $")
+FILE_RCSID("@(#)$File: compress.c,v 1.110 2018/09/09 20:33:28 christos Exp $")
#endif
#include "magic.h"
# ifndef HAVE_SIG_T
typedef void (*sig_t)(int);
# endif /* HAVE_SIG_T */
-#endif
+#endif
#if !defined(__MINGW32__) && !defined(WIN32)
#include <sys/ioctl.h>
#endif
#if defined(HAVE_SYS_TIME_H)
#include <sys/time.h>
#endif
+
#if defined(HAVE_ZLIB_H) && defined(ZLIBSUPPORT)
#define BUILTIN_DECOMPRESS
#include <zlib.h>
#endif
+
+#if defined(HAVE_BZLIB_H)
+#define BUILTIN_BZLIB
+#include <bzlib.h>
+#endif
+
#ifdef DEBUG
int tty = -1;
#define DPRINTF(...) do { \
const void *magic;
size_t maglen;
const char **argv;
+
} compr[] = {
- { "\037\235", 2, gzip_args }, /* compressed */
+ { "\037\235", 2, gzip_args, NULL }, /* compressed */
/* Uncompress can get stuck; so use gzip first if we have it
* Idea from Damien Clark, thanks! */
- { "\037\235", 2, uncompress_args }, /* compressed */
- { "\037\213", 2, gzip_args }, /* gzipped */
- { "\037\236", 2, gzip_args }, /* frozen */
- { "\037\240", 2, gzip_args }, /* SCO LZH */
+ { "\037\235", 2, uncompress_args, NULL }, /* compressed */
+ { "\037\213", 2, gzip_args, do_zlib }, /* gzipped */
+ { "\037\236", 2, gzip_args, NULL }, /* frozen */
+ { "\037\240", 2, gzip_args, NULL }, /* SCO LZH */
/* the standard pack utilities do not accept standard input */
- { "\037\036", 2, gzip_args }, /* packed */
- { "PK\3\4", 4, gzip_args }, /* pkzipped, */
+ { "\037\036", 2, gzip_args, NULL }, /* packed */
+ { "PK\3\4", 4, gzip_args, NULL }, /* pkzipped, */
/* ...only first file examined */
- { "BZh", 3, bzip2_args }, /* bzip2-ed */
- { "LZIP", 4, lzip_args }, /* lzip-ed */
- { "\3757zXZ\0", 6, xz_args }, /* XZ Utils */
- { "LRZI", 4, lrzip_args }, /* LRZIP */
- { "\004\"M\030",4, lz4_args }, /* LZ4 */
- { "\x28\xB5\x2F\xFD", 4, zstd_args }, /* zstd */
+ { "BZh", 3, bzip2_args, do_bzlib }, /* bzip2-ed */
+ { "LZIP", 4, lzip_args, NULL }, /* lzip-ed */
+ { "\3757zXZ\0", 6, xz_args, NULL }, /* XZ Utils */
+ { "LRZI", 4, lrzip_args, NULL }, /* LRZIP */
+ { "\004\"M\030",4, lz4_args, NULL }, /* LZ4 */
+ { "\x28\xB5\x2F\xFD", 4, zstd_args, NULL }, /* zstd */
#ifdef ZLIBSUPPORT
- { RCAST(const void *, zlibcmp), 0, zlib_args }, /* zlib */
+ { RCAST(const void *, zlibcmp), 0, zlib_args, NULL }, /* zlib */
#endif
};
private int uncompressgzipped(const unsigned char *, unsigned char **, size_t,
size_t *);
#endif
+#ifdef BUILTIN_BZLIB
+private int uncompressbzlib(const unsigned char *, unsigned char **, size_t,
+ size_t *, int);
+
static int makeerror(unsigned char **, size_t *, const char *, ...)
__attribute__((__format__(__printf__, 3, 4)));
private const char *methodname(size_t);
int rc;
z_stream z;
- if ((*newch = CAST(unsigned char *, malloc(bytes_max + 1))) == NULL)
+ if ((*newch = CAST(unsigned char *, malloc(bytes_max + 1))) == NULL)
return makeerror(newch, n, "No buffer, %s", strerror(errno));
z.next_in = CCAST(Bytef *, old);
rc = inflateEnd(&z);
if (rc != Z_OK)
goto err;
-
+
/* let's keep the nul-terminate tradition */
(*newch)[*n] = '\0';
int status;
closefd(fdp[STDIN_FILENO], 0);
- /*
+ /*
* fork again, to avoid blocking because both
* pipes filled
*/
fdp[STDIN_FILENO][0] = fd;
(void) lseek(fd, (off_t)0, SEEK_SET);
}
-
+
for (i = 0; i < __arraycount(fdp); i++)
copydesc(CAST(int, i), fdp[i]);
(void)execvp(compr[method].argv[0],
(char *const *)(intptr_t)compr[method].argv);
- dprintf(STDERR_FILENO, "exec `%s' failed, %s",
+ dprintf(STDERR_FILENO, "exec `%s' failed, %s",
compr[method].argv[0], strerror(errno));
exit(1);
/*NOTREACHED*/
closefd(fdp[STDIN_FILENO], 0);
DPRINTF("Returning %p n=%zu rv=%d\n", *newch, *n, rv);
-
+
return rv;
}
#endif
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: der.c,v 1.13 2018/06/23 15:15:26 christos Exp $")
+FILE_RCSID("@(#)$File: der.c,v 1.14 2018/09/09 20:33:28 christos Exp $")
#endif
#endif
static const char *
der_tag(char *buf, size_t len, uint32_t tag)
{
- if (tag < DER_TAG_LONG)
+ if (tag < DER_TAG_LONG)
strlcpy(buf, der__tag[tag], len);
else
snprintf(buf, len, "%#x", tag);
default:
break;
}
-
+
for (uint32_t i = 0; i < len; i++) {
uint32_t z = i << 1;
if (z < blen - 2)
default:
break;
}
-
+
for (uint32_t i = 0; i < len; i++)
printf("%.2x", d[i]);
printf("\n");
if (p + x >= ep)
break;
uint32_t len = getlength(p, &x, ep - p + x);
-
+
printf("%zu %zu-%zu %c,%c,%s,%u:", level, ox, x,
der_class[c], der_type[t],
der_tag(buf, sizeof(buf), tag), len);
* Copyright (c) Ian F. Darwin 1986-1995.
* Software written by Ian F. Darwin and others;
* maintained 1995-present by Christos Zoulas and others.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: dprintf.c,v 1.13 2014/12/04 15:56:46 christos Exp $")
+FILE_RCSID("@(#)$File: dprintf.c,v 1.2 2018/09/09 20:33:28 christos Exp $")
#endif /* lint */
#include <assert.h>
/*
* Copyright (c) Christos Zoulas 2008.
* All Rights Reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
*/
/*
* file.h - definitions for file(1) program
- * @(#)$File: file.h,v 1.196 2018/08/20 10:08:18 christos Exp $
+ * @(#)$File: file.h,v 1.197 2018/09/09 20:33:28 christos Exp $
*/
#ifndef __file_h__
struct tm *localtime_r(const time_t *, struct tm *);
#endif
#ifndef HAVE_FMTCHECK
-const char *fmtcheck(const char *, const char *)
+const char *fmtcheck(const char *, const char *)
__attribute__((__format_arg__(2)));
#endif
#ifdef HAVE_LIBSECCOMP
-// basic filter
+// basic filter
// this mode should not interfere with normal operations
// only some dangerous syscalls are blacklisted
int enable_sandbox_basic(void);
-// enhanced filter
+// enhanced filter
// this mode allows only the necessary syscalls used during normal operation
// extensive testing required !!!
int enable_sandbox_full(void);
EFT f1t, f2t;
if (!f1) return f2;
-
+
f1p = f1;
f1t = FMTCHECK_START;
f2p = f2;
* Copyright (c) Ian F. Darwin 1986-1995.
* Software written by Ian F. Darwin and others;
* maintained 1995-present by Christos Zoulas and others.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: fsmagic.c,v 1.77 2017/05/24 19:17:50 christos Exp $")
+FILE_RCSID("@(#)$File: fsmagic.c,v 1.78 2018/09/09 20:33:28 christos Exp $")
#endif /* lint */
#include "magic.h"
file_error(ms, err,
"broken symbolic link to %s", buf);
return -1;
- }
+ }
if (file_printf(ms, "broken symbolic link to %s", buf) == -1)
return -1;
}
return -1;
#endif
#ifdef S_ISGID
- if (sb->st_mode & S_ISGID)
+ if (sb->st_mode & S_ISGID)
if (file_printf(ms, "%ssetgid", COMMA) == -1)
return -1;
#endif
#ifdef S_ISVTX
- if (sb->st_mode & S_ISVTX)
+ if (sb->st_mode & S_ISVTX)
if (file_printf(ms, "%ssticky", COMMA) == -1)
return -1;
#endif
}
-
+
switch (sb->st_mode & S_IFMT) {
case S_IFDIR:
if (mime) {
break;
#ifdef S_IFCHR
case S_IFCHR:
- /*
+ /*
* If -s has been specified, treat character special files
* like ordinary files. Otherwise, just report that they
* are block special files and go on to the next file.
#endif
#ifdef S_IFBLK
case S_IFBLK:
- /*
+ /*
* If -s has been specified, treat block special files
* like ordinary files. Otherwise, just report that they
* are block special files and go on to the next file.
} else {
if (tmp - fn + 1 > BUFSIZ) {
if (ms->flags & MAGIC_ERROR) {
- file_error(ms, 0,
+ file_error(ms, 0,
"path too long: `%s'", buf);
return -1;
}
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: getopt_long.c,v 1.5 2009/02/03 20:27:51 christos Exp $")
+FILE_RCSID("@(#)$File: getopt_long.c,v 1.7 2018/09/09 20:33:28 christos Exp $")
#endif /* lint */
#include <assert.h>
b = c;
c = a % b;
}
-
+
return b;
}
place = EMSG;
if (IN_ORDER) {
/*
- * GNU extension:
+ * GNU extension:
* return non-option as argument to option 1
*/
optarg = nargv[optind++];
}
if (optchar == 'W' && oli[1] == ';') { /* -W long-option */
/* XXX: what if no long options provided (called by getopt)? */
- if (*place)
+ if (*place)
return -2;
if (++optind >= nargc) { /* no arg */
has_equal++;
} else
current_argv_len = strlen(current_argv);
-
+
for (i = 0; long_options[i].name; i++) {
/* find matching long option */
if (strncmp(current_argv, long_options[i].name,
if (long_options[match].flag) {
*long_options[match].flag = long_options[match].val;
retval = 0;
- } else
+ } else
retval = long_options[match].val;
if (idx)
*idx = match;
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: is_json.c,v 1.9 2018/08/27 06:17:23 christos Exp $")
+FILE_RCSID("@(#)$File: is_json.c,v 1.10 2018/09/09 20:33:28 christos Exp $")
#endif
#include <string.h>
json_isdigit(unsigned char uc)
{
switch (uc) {
- case '0': case '1': case '2': case '3': case '4':
+ case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
return 1;
default:
}
static int
-json_parse_array(const unsigned char **ucp, const unsigned char *ue,
+json_parse_array(const unsigned char **ucp, const unsigned char *ue,
size_t *st, size_t lvl)
{
const unsigned char *uc = *ucp;
}
static int
-json_parse_object(const unsigned char **ucp, const unsigned char *ue,
+json_parse_object(const unsigned char **ucp, const unsigned char *ue,
size_t *st, size_t lvl)
{
const unsigned char *uc = *ucp;
*ucp = uc;
return got;
}
-
+
static int
json_parse_const(const unsigned char **ucp, const unsigned char *ue,
const char *str, size_t len)
}
static int
-json_parse(const unsigned char **ucp, const unsigned char *ue,
+json_parse(const unsigned char **ucp, const unsigned char *ue,
size_t *st, size_t lvl)
{
const unsigned char *uc;
if (uc == ue)
goto out;
- // Avoid recursion
+ // Avoid recursion
if (lvl > 20)
return 0;
#if JSON_COUNT
#if JSON_COUNT
#define P(n) st[n], st[n] > 1 ? "s" : ""
if (file_printf(ms, " (%zu object%s, %zu array%s, %zu string%s, "
- "%zu constant%s, %zu number%s)", P(JSON_OBJECT), P(JSON_ARRAY),
+ "%zu constant%s, %zu number%s)", P(JSON_OBJECT), P(JSON_ARRAY),
P(JSON_STRING), P(JSON_CONSTANT), P(JSON_NUMBER)) == -1)
return -1;
#endif
int getopt_long(int, char * const *, const char *,
const struct option *, int *);
-
+
#endif /* !_GETOPT_H_ */
* Copyright (c) Ian F. Darwin 1986-1995.
* Software written by Ian F. Darwin and others;
* maintained 1995-present by Christos Zoulas and others.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: print.c,v 1.81 2016/01/19 15:09:03 christos Exp $")
+FILE_RCSID("@(#)$File: print.c,v 1.83 2018/09/09 20:33:28 christos Exp $")
#endif /* lint */
#include <string.h>
if (IS_STRING(m->type)) {
if (m->str_flags) {
(void) fputc('/', stderr);
- if (m->str_flags & STRING_COMPACT_WHITESPACE)
+ if (m->str_flags & STRING_COMPACT_WHITESPACE)
(void) fputc(CHAR_COMPACT_WHITESPACE, stderr);
- if (m->str_flags & STRING_COMPACT_OPTIONAL_WHITESPACE)
+ if (m->str_flags & STRING_COMPACT_OPTIONAL_WHITESPACE)
(void) fputc(CHAR_COMPACT_OPTIONAL_WHITESPACE,
stderr);
- if (m->str_flags & STRING_IGNORE_LOWERCASE)
+ if (m->str_flags & STRING_IGNORE_LOWERCASE)
(void) fputc(CHAR_IGNORE_LOWERCASE, stderr);
- if (m->str_flags & STRING_IGNORE_UPPERCASE)
+ if (m->str_flags & STRING_IGNORE_UPPERCASE)
(void) fputc(CHAR_IGNORE_UPPERCASE, stderr);
- if (m->str_flags & REGEX_OFFSET_START)
+ if (m->str_flags & REGEX_OFFSET_START)
(void) fputc(CHAR_REGEX_OFFSET_START, stderr);
if (m->str_flags & STRING_TEXTTEST)
(void) fputc(CHAR_TEXTTEST, stderr);
(void) fputc(optyp[m->mask_op & FILE_OPS_MASK], stderr);
else
(void) fputc('?', stderr);
-
+
if (m->num_mask) {
(void) fprintf(stderr, "%.8llx",
(unsigned long long)m->num_mask);
va_list va;
/* cuz we use stdout for most, stderr here */
- (void) fflush(stdout);
+ (void) fflush(stdout);
if (ms->file)
(void) fprintf(stderr, "%s, %lu: ", ms->file,
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: readcdf.c,v 1.69 2018/08/19 10:38:21 christos Exp $")
+FILE_RCSID("@(#)$File: readcdf.c,v 1.70 2018/09/09 20:33:28 christos Exp $")
#endif
#include <assert.h>
#ifdef notdef
private char *
format_clsid(char *buf, size_t len, const uint64_t uuid[2]) {
- snprintf(buf, len, "%.8" PRIx64 "-%.4" PRIx64 "-%.4" PRIx64 "-%.4"
+ snprintf(buf, len, "%.8" PRIx64 "-%.4" PRIx64 "-%.4" PRIx64 "-%.4"
PRIx64 "-%.12" PRIx64,
(uuid[0] >> 32) & (uint64_t)0x000000000ffffffffULL,
(uuid[0] >> 16) & (uint64_t)0x0000000000000ffffULL,
- (uuid[0] >> 0) & (uint64_t)0x0000000000000ffffULL,
+ (uuid[0] >> 0) & (uint64_t)0x0000000000000ffffULL,
(uuid[1] >> 48) & (uint64_t)0x0000000000000ffffULL,
(uuid[1] >> 0) & (uint64_t)0x0000fffffffffffffULL);
return buf;
const char *sections[5];
const int types[5];
} sectioninfo[] = {
- { "Encrypted", "encrypted",
+ { "Encrypted", "encrypted",
{
"EncryptedPackage", "EncryptedSummary",
NULL, NULL, NULL,
},
},
- { "QuickBooks", "quickbooks",
+ { "QuickBooks", "quickbooks",
{
#if 0
"TaxForms", "PDFTaxForms", "modulesInBackup",
/*
* Copyright (c) Christos Zoulas 2003.
* All Rights Reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: readelf.c,v 1.151 2018/08/03 09:00:13 christos Exp $")
+FILE_RCSID("@(#)$File: readelf.c,v 1.152 2018/09/09 20:33:28 christos Exp $")
#endif
#ifdef BUILTIN_ELF
retval.c[0] = tmpval.c[1];
retval.c[1] = tmpval.c[0];
-
+
return retval.ui;
} else
return value;
retval.c[1] = tmpval.c[2];
retval.c[2] = tmpval.c[1];
retval.c[3] = tmpval.c[0];
-
+
return retval.ui;
} else
return value;
retval.c[5] = tmpval.c[2];
retval.c[6] = tmpval.c[1];
retval.c[7] = tmpval.c[0];
-
+
return retval.ui;
} else
return value;
* Contents is __FreeBSD_version, whose relation to OS
* versions is defined by a huge table in the Porter's
* Handbook. This is the general scheme:
- *
+ *
* Releases:
* Mmp000 (before 4.10)
* Mmi0p0 (before 5.0)
* Mmm0p0
- *
+ *
* Development branches:
* Mmpxxx (before 4.6)
* Mmp1xx (before 4.10)
* Mmi1xx (before 5.0)
* M000xx (pre-M.0)
* Mmm1xx
- *
+ *
* M = major version
* m = minor version
* i = minor version increment (491000 -> 4.10)
* p = patchlevel
* x = revision
- *
+ *
* The first release of FreeBSD to use ELF by default
* was version 3.0.
*/
break;
default:
if (file_printf(ms, "<unknown>") == -1)
- return 1;
+ return 1;
}
if (file_printf(ms, " %d.%d.%d", elf_getu32(swap, desc[1]),
elf_getu32(swap, desc[2]), elf_getu32(swap, desc[3])) == -1)
if ((namesz == 4 && strncmp((char *)&nbuf[noff], "CORE", 4) == 0) ||
(namesz == 5 && strcmp((char *)&nbuf[noff], "CORE") == 0)) {
os_style = OS_STYLE_SVR4;
- }
+ }
if ((namesz == 8 && strcmp((char *)&nbuf[noff], "FreeBSD") == 0)) {
os_style = OS_STYLE_FREEBSD;
if (buflen == 0)
continue;
-
+
if (file_printf(ms, ", %s: '%s'", tag, buf) == -1)
return 0;
} else {
namesz, descsz, noff, doff, flags))
return offset;
}
-
+
if ((*flags & FLAGS_DID_NETBSD_PAX) == 0) {
if (do_pax_note(ms, nbuf, xnh_type, swap,
namesz, descsz, noff, doff, flags))
CAST(uintmax_t, xsh_size),
CAST(uintmax_t, fsize)) == -1)
return -1;
- return 0;
+ return 0;
}
if ((nbuf = malloc(xsh_size)) == NULL) {
file_error(ms, errno, "Cannot allocate memory"
return -1;
break;
}
- // gnu attributes
+ // gnu attributes
#endif
break;
}
char interp[BUFSIZ];
ssize_t bufsize;
size_t offset, align, len;
-
+
if (num == 0) {
if (file_printf(ms, ", no program header") == -1)
return -1;
interp[0] = '\0';
for ( ; num; num--) {
int doread;
- if (pread(fd, xph_addr, xph_sizeof, off) <
+ if (pread(fd, xph_addr, xph_sizeof, off) <
CAST(ssize_t, xph_sizeof)) {
file_badread(ms);
return -1;
continue;
if (((align = xph_align) & 0x80000000UL) != 0 ||
align < 4) {
- if (file_printf(ms,
+ if (file_printf(ms,
", invalid note alignment %#lx",
CAST(unsigned long, align)) == -1)
return -1;
/*
* Copyright (c) Christos Zoulas 2003.
* All Rights Reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
#define GNU_OS_KNETBSD 4
/*
- * GNU Hardware capability information
+ * GNU Hardware capability information
* word[0]: Number of entries
* word[1]: Bitmask of enabled entries
* Followed by a byte id, and a NUL terminated string per entry
/*
* GNU Build ID generated by ld
- * 160 bit SHA1 [default]
+ * 160 bit SHA1 [default]
* 128 bit md5 or uuid
*/
#define NT_GNU_BUILD_ID 3
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: seccomp.c,v 1.6 2018/06/26 20:29:29 christos Exp $")
+FILE_RCSID("@(#)$File: seccomp.c,v 1.7 2018/09/09 20:33:28 christos Exp $")
#endif /* lint */
#if HAVE_LIBSECCOMP
DENY_RULE (socket);
// ...
-
+
// applying filter...
if (seccomp_load (ctx) == -1)
goto out;
// free ctx after the filter has been loaded into the kernel
seccomp_release(ctx);
return 0;
-
+
out:
seccomp_release(ctx);
return -1;
if (prctl(PR_SET_DUMPABLE, 0, 0, 0, 0) == -1)
return -1;
-
+
// initialize the filter
ctx = seccomp_init(SCMP_ACT_KILL);
if (ctx == NULL)
ALLOW_RULE(dup2);
ALLOW_RULE(exit);
ALLOW_RULE(exit_group);
- ALLOW_RULE(fcntl);
- ALLOW_RULE(fcntl64);
+ ALLOW_RULE(fcntl);
+ ALLOW_RULE(fcntl64);
ALLOW_RULE(fstat);
- ALLOW_RULE(fstat64);
+ ALLOW_RULE(fstat64);
ALLOW_RULE(getdents);
#ifdef __NR_getdents64
ALLOW_RULE(getdents64);
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: softmagic.c,v 1.269 2018/08/21 08:58:16 christos Exp $")
+FILE_RCSID("@(#)$File: softmagic.c,v 1.270 2018/09/09 20:33:28 christos Exp $")
#endif /* lint */
#include "magic.h"
const struct buffer *, size_t, int, int, int, uint16_t *,
uint16_t *, int *, int *, int *);
private int mget(struct magic_set *, struct magic *, const struct buffer *,
- const unsigned char *, size_t,
+ const unsigned char *, size_t,
size_t, unsigned int, int, int, int, uint16_t *,
uint16_t *, int *, int *, int *);
private int msetoffset(struct magic_set *, struct magic *, struct buffer *,
case FILE_BESTRING16:
case FILE_LESTRING16:
if (m->reln == '=' || m->reln == '!') {
- if (file_printf(ms, F(ms, desc, "%s"),
+ if (file_printf(ms, F(ms, desc, "%s"),
file_printable(sbuf, sizeof(sbuf), m->value.s))
== -1)
return -1;
t = ms->offset;
break;
case FILE_DER:
- if (file_printf(ms, F(ms, desc, "%s"),
+ if (file_printf(ms, F(ms, desc, "%s"),
file_printable(sbuf, sizeof(sbuf), ms->ms_value.s)) == -1)
return -1;
t = ms->offset;
* 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 = sz;
}
while (len--)
goto out;
return 1;
case FILE_BEDOUBLE:
- p->q = BE64(p);
+ p->q = BE64(p);
if (cvt_double(p, m) == -1)
goto out;
return 1;
* Copyright (c) Ian F. Darwin 1986-1995.
* Software written by Ian F. Darwin and others;
* maintained 1995-present by Christos Zoulas and others.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
the following disclaimer in the documentation and/or other materials
provided with the distribution. The name of the author may not be used to
endorse or promote products derived from this software without specific
-prior written permission.
+prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: vasprintf.c,v 1.14 2017/08/13 00:21:47 christos Exp $")
+FILE_RCSID("@(#)$File: vasprintf.c,v 1.15 2018/09/09 20:33:28 christos Exp $")
#endif /* lint */
#include <assert.h>