Spint fiddles.

CVS patchset: 7394
CVS date: 2004/08/04 03:42:35
This commit is contained in:
jbj 2004-08-04 03:42:35 +00:00
parent 20c3ac1c50
commit e71a58fece
14 changed files with 301 additions and 113 deletions

View File

@ -1,23 +1,29 @@
LINT = splint
BUILT_SOURCES = listobjs
MAGIC = $(pkgdatadir)/magic
#MAGIC = $(pkgdatadir)/magic
pkglibdir = @prefix@/lib/rpm
MAGIC = $(pkglibdir)/magic
AM_CPPFLAGS = -DMAGIC='"$(MAGIC)"'
include_HEADERS = magic.h
noinst_HEADERS = file.h names.h patchlevel.h readelf.h tar.h
include_HEADERS = # magic.h
noinst_HEADERS = file.h magic.h names.h patchlevel.h readelf.h tar.h
#lib_LTLIBRARIES = libmagic.la
usrlibdir = $(libdir)@MARK64@
usrlib_LTLIBRARIES = libmagic.la
#usrlibdir = $(libdir)@MARK64@
#usrlib_LTLIBRARIES = libmagic.la
noinst_LTLIBRARIES = libmagic.la
libmagic_la_SOURCES = magic.c apprentice.c softmagic.c ascmagic.c \
compress.c is_tar.c readelf.c print.c fsmagic.c \
funcs.c file.h names.h patchlevel.h readelf.h tar.h apptype.c
funcs.c apptype.c
libmagic_la_LDFLAGS = -version-info 1:0:0
bin_PROGRAMS = file
#bin_PROGRAMS = file
noinst_PROGRAMS = file
file_SOURCES = file.c
file_LDFLAGS = -all-static
file_LDADD = libmagic.la
listobjs:
@ -30,4 +36,3 @@ lint:
.PHONY: sources
sources:
@echo $(libmagic_la_SOURCES:%=file/src/%)

View File

@ -79,28 +79,56 @@ FILE_RCSID("@(#)$Id: apprentice.c,v 1.78 2004/07/24 20:38:56 christos Exp $")
#define MAXPATHLEN 1024
#endif
private int getvalue(struct magic_set *ms, struct magic *, char **);
private int hextoint(int);
private char *getstr(struct magic_set *, char *, char *, int, int *);
private int parse(struct magic_set *, struct magic **, uint32_t *, char *, int);
private void eatsize(char **);
private int apprentice_1(struct magic_set *, const char *, int, struct mlist *);
private int apprentice_file(struct magic_set *, struct magic **, uint32_t *,
const char *, int);
private void byteswap(struct magic *, uint32_t);
private void bs1(struct magic *);
private uint16_t swap2(uint16_t);
private uint32_t swap4(uint32_t);
private char *mkdbname(const char *, char *, size_t);
private int apprentice_map(struct magic_set *, struct magic **, uint32_t *,
const char *);
private int apprentice_compile(struct magic_set *, struct magic **, uint32_t *,
const char *);
private int check_format(struct magic *);
/*@unchecked@*/
private size_t maxmagic = 0;
/*@unchecked@*/
private size_t magicsize = sizeof(struct magic);
private int getvalue(struct magic_set *ms, struct magic *m, char **p)
/*@globals fileSystem @*/
/*@modifies ms, m, *p, fileSystem @*/;
private int hextoint(int c)
/*@*/;
/*@null@*/
private char *getstr(struct magic_set *ms, char *s, char *p, int plen,
int *slen)
/*@modifies ms, *p, *slen @*/;
private int parse(struct magic_set *ms, struct magic **magicp,
uint32_t *nmagicp, char *l, int action)
/*@globals maxmagic, fileSystem @*/
/*@modifies ms, *magicp, *nmagicp, maxmagic, fileSystem @*/;
private void eatsize(char **p)
/*@modifies *p @*/;
private int apprentice_1(struct magic_set *ms, const char *fn, int action,
struct mlist *mlist)
/*@globals fileSystem, internalState @*/
/*@modifies ms, mlist, fileSystem, internalState @*/;
private int apprentice_file(struct magic_set *ms, struct magic **magicp,
uint32_t *nmagicp, const char *fn, int action)
/*@globals maxmagic, fileSystem @*/
/*@modifies ms, *magicp, *nmagicp, maxmagic, fileSystem @*/;
private void byteswap(struct magic *magic, uint32_t nmagic)
/*@modifies magic @*/;
private void bs1(struct magic *m)
/*@modifies m @*/;
private uint16_t swap2(uint16_t sv)
/*@*/;
private uint32_t swap4(uint32_t sv)
/*@*/;
private char *mkdbname(const char *fn, char *buf, size_t bufsiz)
/*@modifies buf @*/;
private int apprentice_map(struct magic_set *ms, struct magic **magicp,
uint32_t *nmagicp, const char *fn)
/*@globals fileSystem, internalState @*/
/*@modifies ms, *magicp, *nmagicp, fileSystem, internalState @*/;
private int apprentice_compile(struct magic_set *ms, struct magic **magicp,
uint32_t *nmagicp, const char *fn)
/*@globals fileSystem, internalState @*/
/*@modifies ms, fileSystem, internalState @*/;
private int check_format(struct magic *m)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
#ifdef COMPILE_ONLY
int main(int, char *[]);
@ -213,7 +241,7 @@ file_delmagic(struct magic *p, int type, size_t entries)
break;
case 1:
p--;
/*FALLTHROUGH*/
/*@fallthrough@*/
case 0:
free(p);
break;
@ -396,6 +424,7 @@ parse(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp, char *l,
int i = 0;
struct magic *m;
char *t;
/*@observer@*/
private const char *fops = FILE_OPS;
uint32_t val;
@ -674,7 +703,7 @@ parse(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp, char *l,
++l;
break;
}
/*FALLTHROUGH*/
/*@fallthrough@*/
default:
if (*l == 'x' && isascii((unsigned char)l[1]) &&
isspace((unsigned char)l[1])) {
@ -732,7 +761,11 @@ GetDesc:
private int
check_format(struct magic *m)
{
/*@-nullassign@*/
/*@observer@*/
static const char *formats[] = { FILE_FORMAT_STRING };
/*@=nullassign@*/
/*@observer@*/
static const char *names[] = { FILE_FORMAT_NAME };
char *ptr;
@ -1004,7 +1037,7 @@ eatsize(char **p)
case 'b': /* char/byte */
case 'c': /* char/byte */
l++;
/*FALLTHROUGH*/
/*@fallthrough@*/
default:
break;
}
@ -1104,6 +1137,7 @@ error:
return -1;
}
/*@unchecked@*/ /*@observer@*/
private const uint32_t ar[] = {
MAGICNO, VERSIONNO
};
@ -1147,6 +1181,7 @@ apprentice_compile(struct magic_set *ms, struct magic **magicp,
return 0;
}
/*@unchecked@*/ /*@observer@*/
private const char ext[] = ".mgc";
/*
* make a dbname

View File

@ -63,13 +63,26 @@ typedef unsigned long unichar;
#define ISSPC(x) ((x) == ' ' || (x) == '\t' || (x) == '\r' || (x) == '\n' \
|| (x) == 0x85 || (x) == '\f')
private int looks_ascii(const unsigned char *, size_t, unichar *, size_t *);
private int looks_utf8(const unsigned char *, size_t, unichar *, size_t *);
private int looks_unicode(const unsigned char *, size_t, unichar *, size_t *);
private int looks_latin1(const unsigned char *, size_t, unichar *, size_t *);
private int looks_extended(const unsigned char *, size_t, unichar *, size_t *);
private void from_ebcdic(const unsigned char *, size_t, unsigned char *);
private int ascmatch(const unsigned char *, const unichar *, size_t);
private int looks_ascii(const unsigned char *buf, size_t nbytes,
unichar *ubuf, size_t *ulen)
/*@modifies *ubuf, *ulen @*/;
private int looks_utf8(const unsigned char *buf, size_t nbytes,
unichar *ubuf, size_t *ulen)
/*@modifies *ubuf, *ulen @*/;
private int looks_unicode(const unsigned char *buf, size_t nbytes,
unichar *ubuf, size_t *ulen)
/*@modifies *ubuf, *ulen @*/;
private int looks_latin1(const unsigned char *buf, size_t nbytes,
unichar *ubuf, size_t *ulen)
/*@modifies *ubuf, *ulen @*/;
private int looks_extended(const unsigned char *buf, size_t nbytes,
unichar *ubuf, size_t *ulen)
/*@modifies *ubuf, *ulen @*/;
private void from_ebcdic(const unsigned char *buf, size_t nbytes,
unsigned char *out)
/*@modifies *out @*/;
private int ascmatch(const unsigned char *s, const unichar *us, size_t ulen)
/*@*/;
protected int
@ -417,6 +430,7 @@ ascmatch(const unsigned char *s, const unichar *us, size_t ulen)
#define I 2 /* character appears in ISO-8859 text */
#define X 3 /* character appears in non-ISO extended ASCII (Mac, IBM PC) */
/*@unchecked@*/ /*@observer@*/
private char text_chars[256] = {
/* BEL BS HT LF FF CR */
F, F, F, F, F, F, F, T, T, T, T, F, T, T, F, F, /* 0x0X */
@ -624,6 +638,7 @@ looks_unicode(const unsigned char *buf, size_t nbytes, unichar *ubuf,
* between old-style and internationalized examples of text.
*/
/*@unchecked@*/ /*@observer@*/
private unsigned char ebcdic_to_ascii[] = {
0, 1, 2, 3, 156, 9, 134, 127, 151, 141, 142, 11, 12, 13, 14, 15,
16, 17, 18, 19, 157, 133, 8, 135, 24, 25, 146, 143, 28, 29, 30, 31,

View File

@ -59,9 +59,13 @@ FILE_RCSID("@(#)$Id: compress.c,v 1.37 2004/07/24 21:00:56 christos Exp $")
#endif
/*@-nullassign@*/
/*@unchecked@*/ /*@observer@*/
private struct {
/*@observer@*/
const char *magic;
size_t maglen;
/*@observer@*/
const char *const argv[3];
int silent;
} compr[] = {
@ -76,17 +80,24 @@ private struct {
{ "\037\036", 2, { "gzip", "-cdq", NULL }, 0 }, /* packed */
{ "BZh", 3, { "bzip2", "-cd", NULL }, 1 }, /* bzip2-ed */
};
/*@=nullassign@*/
/*@unchecked@*/
private int ncompr = sizeof(compr) / sizeof(compr[0]);
private ssize_t swrite(int, const void *, size_t);
private ssize_t sread(int, void *, size_t);
private size_t uncompressbuf(struct magic_set *, size_t, const unsigned char *,
unsigned char **, size_t);
private ssize_t swrite(int fd, const void *buf, size_t n)
/*@*/;
private ssize_t sread(int fd, void *buf, size_t n)
/*@modifies buf @*/;
private size_t uncompressbuf(struct magic_set *ms, size_t method,
const unsigned char *old, unsigned char **newch, size_t n)
/*@globals fileSystem, internalState @*/
/*@modifies ms, *newch, fileSystem, internalState @*/;
#ifdef HAVE_LIBZ
private size_t uncompressgzipped(struct magic_set *, const unsigned char *,
unsigned char **, size_t);
private size_t uncompressgzipped(struct magic_set *ms, const unsigned char *old,
unsigned char **newch, size_t n)
/*@modifies ms, *newch @*/;
#endif
protected int
@ -348,7 +359,7 @@ uncompressbuf(struct magic_set *ms, size_t method, const unsigned char *old,
execvp(compr[method].argv[0],
(char *const *)compr[method].argv);
exit(1);
/*NOTREACHED*/
/*@notreached@*/ break;
case -1:
file_error(ms, errno, "could not fork");
return 0;
@ -363,11 +374,11 @@ uncompressbuf(struct magic_set *ms, size_t method, const unsigned char *old,
if (swrite(fdin[1], old, n) != n)
exit(1);
exit(0);
/*NOTREACHED*/
/*@notreached@*/ break;
case -1:
exit(1);
/*NOTREACHED*/
/*@notreached@*/ break;
default: /* parent */
break;
@ -400,4 +411,5 @@ err:
#endif
return n;
}
/*@notreached@*/
}

View File

@ -93,32 +93,49 @@ FILE_RCSID("@(#)$Id: file.c,v 1.93 2004/04/07 14:23:55 christos Exp $")
#define MAXPATHLEN 512
#endif
/*@unchecked@*/
private int /* Global command-line options */
bflag = 0, /* brief output format */
nopad = 0, /* Don't pad output */
nobuffer = 0; /* Do not buffer stdout */
/*@unchecked@*/ /*@null@*/
private const char *magicfile = 0; /* where the magic is */
/*@unchecked@*/ /*@observer@*/
private const char *default_magicfile = MAGIC;
/*@unchecked@*/ /*@observer@*/
private char *separator = ":"; /* Default field separator */
/*@unchecked@*/ /*@null@*/
private char *progname; /* used throughout */
/*@unchecked@*/ /*@null@*/
private struct magic_set *magic;
private void unwrap(char *);
private void usage(void);
private void unwrap(char *fn)
/*@globals fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/;
private void usage(void)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
#ifdef HAVE_GETOPT_LONG
private void help(void);
private void help(void)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
#endif
#if 0
private int byteconv4(int, int, int);
private short byteconv2(int, int, int);
private int byteconv4(int from, int same, int big_endian)
/*@*/;
private short byteconv2(int from, int same, int big_endian)
/*@*/;
#endif
int main(int, char *[]);
private void process(const char *, int);
private void load(const char *, int);
private void process(const char *inname, int wid)
/*@globals magic, fileSystem, internalState @*/
/*@modifies magic, fileSystem, internalState @*/;
private void load(const char *m, int flags)
/*@globals magic, fileSystem, internalState @*/
/*@modifies magic, fileSystem, internalState @*/;
/*
@ -126,6 +143,12 @@ private void load(const char *, int);
*/
int
main(int argc, char *argv[])
/*@globals bflag, default_magicfile, magic, magicfile,
nobuffer, nopad, optind, progname, separator,
fileSystem, internalState @*/
/*@modifies argv, bflag, default_magicfile, magic, magicfile,
nobuffer, nopad, optind, progname, separator,
fileSystem, internalState @*/
{
int c;
int action = 0, didsomefiles = 0, errflg = 0;
@ -135,6 +158,8 @@ main(int argc, char *argv[])
#define OPTSTRING "bcCdf:F:ikLm:nNprsvz"
#ifdef HAVE_GETOPT_LONG
int longindex;
/*@observer@*/
/*@-nullassign -readonlytrans@*/
private struct option long_options[] =
{
{"version", 0, 0, 'v'},
@ -161,6 +186,7 @@ main(int argc, char *argv[])
{"compile", 0, 0, 'C'},
{0, 0, 0, 0},
};
/*@=nullassign =readonlytrans@*/
#endif
#ifdef LC_CTYPE
@ -320,7 +346,7 @@ main(int argc, char *argv[])
private void
load(const char *m, int flags)
load(/*@unused@*/ const char *m, int flags)
{
if (magic)
return;

View File

@ -216,6 +216,7 @@ struct mlist {
};
struct magic_set {
/*@null@*/
struct mlist *mlist;
struct cont {
size_t len;
@ -237,29 +238,65 @@ struct magic_set {
};
struct stat;
protected char *file_fmttime(uint32_t, int);
protected int file_buffer(struct magic_set *, const void *, size_t);
protected int file_fsmagic(struct magic_set *, const char *, struct stat *);
protected int file_pipe2file(struct magic_set *, int, const void *, size_t);
protected int file_printf(struct magic_set *, const char *, ...);
protected int file_reset(struct magic_set *);
protected int file_tryelf(struct magic_set *, int, const unsigned char *, size_t);
protected int file_zmagic(struct magic_set *, const unsigned char *, size_t);
protected int file_ascmagic(struct magic_set *, const unsigned char *, size_t);
protected int file_is_tar(struct magic_set *, const unsigned char *, size_t);
protected int file_softmagic(struct magic_set *, const unsigned char *, size_t);
protected struct mlist *file_apprentice(struct magic_set *, const char *, int);
protected uint32_t file_signextend(struct magic_set *, struct magic *, uint32_t);
protected void file_delmagic(struct magic *, int type, size_t entries);
protected void file_badread(struct magic_set *);
protected void file_badseek(struct magic_set *);
protected void file_oomem(struct magic_set *);
protected void file_error(struct magic_set *, int, const char *, ...);
protected void file_magwarn(const char *, ...);
protected void file_mdump(struct magic *);
protected void file_showstr(FILE *, const char *, size_t);
protected size_t file_mbswidth(const char *);
protected const char *file_getbuffer(struct magic_set *);
protected char *file_fmttime(uint32_t, int)
/*@*/;
protected int file_buffer(struct magic_set *ms, const void *, size_t)
/*@globals fileSystem, internalState @*/
/*@modifies ms, fileSystem, internalState @*/;
protected int file_fsmagic(struct magic_set *ms, const char *, struct stat *sb)
/*@modifies ms, sb @*/;
protected int file_pipe2file(struct magic_set *ms, int fd, const void *startbuf,
size_t nbytes)
/*@globals errno, fileSystem, internalState @*/
/*@modifies ms, errno, fileSystem, internalState @*/;
protected int file_printf(struct magic_set *ms, const char *, ...)
/*@modifies ms @*/;
protected int file_reset(struct magic_set *ms)
/*@modifies ms @*/;
protected int file_tryelf(struct magic_set *ms, int, const unsigned char *, size_t)
/*@globals fileSystem, internalState @*/
/*@modifies ms, fileSystem, internalState @*/;
protected int file_zmagic(struct magic_set *ms, const unsigned char *, size_t)
/*@globals fileSystem, internalState @*/
/*@modifies ms, fileSystem, internalState @*/;
protected int file_ascmagic(struct magic_set *ms, const unsigned char *, size_t)
/*@modifies ms @*/;
protected int file_is_tar(struct magic_set *ms, const unsigned char *, size_t)
/*@modifies ms @*/;
protected int file_softmagic(struct magic_set *ms, const unsigned char *, size_t)
/*@globals fileSystem @*/
/*@modifies ms, fileSystem @*/;
/*@null@*/
protected struct mlist *file_apprentice(struct magic_set *ms, const char *, int)
/*@globals fileSystem, internalState @*/
/*@modifies ms, fileSystem, internalState @*/;
protected uint32_t file_signextend(struct magic_set *ms, struct magic *, uint32_t)
/*@globals fileSystem @*/
/*@modifies ms, fileSystem @*/;
protected void file_delmagic(struct magic *p, int type, size_t entries)
/*@globals fileSystem @*/
/*@modifies p, fileSystem @*/;
protected void file_badread(struct magic_set *ms)
/*@modifies ms @*/;
protected void file_badseek(struct magic_set *ms)
/*@modifies ms @*/;
protected void file_oomem(struct magic_set *ms)
/*@modifies ms @*/;
protected void file_error(struct magic_set *ms, int, const char *, ...)
/*@modifies ms @*/;
protected void file_magwarn(const char *f, ...)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
protected void file_mdump(struct magic *m)
/*@globals fileSystem @*/
/*@modifies m, fileSystem @*/;
protected void file_showstr(FILE *fp, const char *s, size_t len)
/*@globals fileSystem @*/
/*@modifies fp, fileSystem @*/;
protected size_t file_mbswidth(const char *)
/*@*/;
protected const char *file_getbuffer(struct magic_set *ms)
/*@modifies ms @*/;
#ifndef HAVE_STRERROR
extern int sys_nerr;

View File

@ -290,7 +290,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
default:
file_error(ms, 0, "invalid mode 0%o", sb->st_mode);
return -1;
/*NOTREACHED*/
/*@notreached@*/
}
/*

View File

@ -55,8 +55,10 @@ FILE_RCSID("@(#)$Id: is_tar.c,v 1.24 2003/11/11 20:01:46 christos Exp $")
#define isodigit(c) ( ((c) >= '0') && ((c) <= '7') )
private int is_tar(const unsigned char *, size_t);
private int from_oct(int, const char *); /* Decode octal number */
private int is_tar(const unsigned char *buf, size_t nbytes)
/*@*/;
private int from_oct(int digs, const char *where)
/*@*/;
protected int
file_is_tar(struct magic_set *ms, const unsigned char *buf, size_t nbytes)

View File

@ -74,9 +74,13 @@ protected int file_os2_apptype(struct magic_set *ms, const char *fn,
const void *buf, size_t nb);
#endif /* __EMX__ */
private void free_mlist(struct mlist *);
private void close_and_restore(const struct magic_set *, const char *, int,
const struct stat *);
private void free_mlist(struct mlist *mlist)
/*@globals fileSystem @*/
/*@modifies mlist, fileSystem @*/;
private void close_and_restore(const struct magic_set *ms, const char *name,
int fd, const struct stat *sb)
/*@globals fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/;
public struct magic_set *
magic_open(int flags)
@ -136,8 +140,7 @@ free_mlist(struct mlist *mlist)
}
public void
magic_close(ms)
struct magic_set *ms;
magic_close(struct magic_set *ms)
{
free_mlist(ms->mlist);
free(ms->o.buf);

View File

@ -48,19 +48,40 @@ extern "C" {
#endif
typedef struct magic_set *magic_t;
magic_t magic_open(int);
void magic_close(magic_t);
const char *magic_file(magic_t, const char *);
const char *magic_buffer(magic_t, const void *, size_t);
/*@null@*/
magic_t magic_open(int)
/*@globals errno @*/
/*@modifies errno @*/;
void magic_close(magic_t ms)
/*@globals fileSystem @*/
/*@modifies ms, fileSystem @*/;
const char *magic_error(magic_t);
int magic_setflags(magic_t, int);
/*@null@*/
const char *magic_file(magic_t ms, const char *)
/*@globals fileSystem, internalState @*/
/*@modifies ms, fileSystem, internalState @*/;
/*@null@*/
const char *magic_buffer(magic_t ms, const void *, size_t)
/*@globals fileSystem, internalState @*/
/*@modifies ms, fileSystem, internalState @*/;
int magic_load(magic_t, const char *);
int magic_compile(magic_t, const char *);
int magic_check(magic_t, const char *);
int magic_errno(magic_t);
const char *magic_error(magic_t ms)
/*@modifies ms @*/;
int magic_setflags(magic_t ms, int)
/*@modifies ms @*/;
int magic_load(magic_t ms, const char *)
/*@globals fileSystem, internalState @*/
/*@modifies ms, fileSystem, internalState @*/;
int magic_compile(magic_t ms, const char *)
/*@globals fileSystem, internalState @*/
/*@modifies ms, fileSystem, internalState @*/;
int magic_check(magic_t ms, const char *magicfile)
/*@globals fileSystem, internalState @*/
/*@modifies ms, fileSystem, internalState @*/;
int magic_errno(magic_t ms)
/*@modifies ms @*/;
#ifdef __cplusplus
};

View File

@ -62,8 +62,11 @@
#define L_M4 13 /* M4 */
#define L_PO 14 /* PO */
/*@unchecked@*/ /*@observer@*/
static const struct {
/*@observer@*/ /*@null@*/
const char *human;
/*@observer@*/ /*@null@*/
const char *mime;
} types[] = {
{ "C program", "text/x-c", },
@ -121,7 +124,9 @@ static const struct {
* as Java, as it comes after "the" and "The". Perhaps we need a fancier
* heuristic to identify Java?
*/
/*@unchecked@*/ /*@observer@*/
static struct names {
/*@observer@*/ /*@null@*/
const char *name;
short type;
} names[] = {

View File

@ -55,6 +55,7 @@ FILE_RCSID("@(#)$Id: print.c,v 1.44 2003/09/12 19:39:44 christos Exp $")
protected void
file_mdump(struct magic *m)
{
/*@observer@*/
private const char *typ[] = { "invalid", "byte", "short", "invalid",
"long", "string", "date", "beshort",
"belong", "bedate", "leshort", "lelong",

View File

@ -43,18 +43,28 @@ FILE_RCSID("@(#)$Id: readelf.c,v 1.42 2004/07/24 20:57:22 christos Exp $")
#endif
#ifdef ELFCORE
private int dophn_core(struct magic_set *, int, int, int, off_t, int, size_t);
private int dophn_core(struct magic_set *ms, int class, int swap, int fd,
off_t off, int num, size_t size)
/*@modifies ms @*/;
#endif
private int dophn_exec(struct magic_set *, int, int, int, off_t, int, size_t);
private int doshn(struct magic_set *, int, int, int, off_t, int, size_t);
private size_t donote(struct magic_set *, unsigned char *, size_t, size_t, int,
int, size_t);
private int dophn_exec(struct magic_set *ms, int class, int swap, int fd,
off_t off, int num, size_t size)
/*@modifies ms @*/;
private int doshn(struct magic_set *ms, int class, int swap, int fd, off_t off,
int num, size_t size)
/*@modifies ms @*/;
private size_t donote(struct magic_set *ms, unsigned char *nbuf, size_t offset,
size_t size, int class, int swap, size_t align)
/*@modifies ms @*/;
#define ELF_ALIGN(a) ((((a) + align - 1) / align) * align)
private uint16_t getu16(int, uint16_t);
private uint32_t getu32(int, uint32_t);
private uint64_t getu64(int, uint64_t);
private uint16_t getu16(int swap, uint16_t value)
/*@*/;
private uint32_t getu32(int swap, uint32_t value)
/*@*/;
private uint64_t getu64(int swap, uint64_t value)
/*@*/;
private uint16_t
getu16(int swap, uint16_t value)
@ -170,6 +180,7 @@ getu64(int swap, uint64_t value)
: prpsoffsets64[i])
#ifdef ELFCORE
/*@unchecked@*/ /*@observer@*/
size_t prpsoffsets32[] = {
8, /* FreeBSD */
28, /* Linux 2.0.36 */
@ -177,6 +188,7 @@ size_t prpsoffsets32[] = {
84, /* SunOS 5.x */
};
/*@unchecked@*/ /*@observer@*/
size_t prpsoffsets64[] = {
120, /* SunOS 5.x, 64-bit */
};
@ -211,6 +223,7 @@ size_t prpsoffsets64[] = {
#define OS_STYLE_FREEBSD 1
#define OS_STYLE_NETBSD 2
/*@unchecked@*/ /*@observer@*/
private const char *os_style_names[] = {
"SVR4",
"FreeBSD",

View File

@ -47,15 +47,28 @@
FILE_RCSID("@(#)$Id: softmagic.c,v 1.66 2004/07/24 20:38:56 christos Exp $")
#endif /* lint */
private int match(struct magic_set *, struct magic *, uint32_t,
const unsigned char *, size_t);
private int mget(struct magic_set *, union VALUETYPE *, const unsigned char *,
struct magic *, size_t);
private int mcheck(struct magic_set *, union VALUETYPE *, struct magic *);
private int32_t mprint(struct magic_set *, union VALUETYPE *, struct magic *);
private void mdebug(uint32_t, const char *, size_t);
private int mconvert(struct magic_set *, union VALUETYPE *, struct magic *);
private int check_mem(struct magic_set *, unsigned int);
private int match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
const unsigned char *s, size_t nbytes)
/*@globals fileSystem @*/
/*@modifies ms, magic, fileSystem @*/;
private int mget(struct magic_set *ms, union VALUETYPE *p,
const unsigned char *s, struct magic *m, size_t nbytes)
/*@globals fileSystem @*/
/*@modifies ms, p, m, fileSystem @*/;
private int mcheck(struct magic_set *ms, union VALUETYPE *p, struct magic *m)
/*@globals fileSystem @*/
/*@modifies ms, p, fileSystem @*/;
private int32_t mprint(struct magic_set *ms, union VALUETYPE *p,
struct magic *m)
/*@globals fileSystem @*/
/*@modifies ms, p, fileSystem @*/;
private void mdebug(uint32_t offset, const char *str, size_t len)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
private int mconvert(struct magic_set *ms, union VALUETYPE *p, struct magic *m)
/*@modifies ms, p @*/;
private int check_mem(struct magic_set *ms, unsigned int level)
/*@modifies ms @*/;
/*
* softmagic - lookup one file in database