From a338ea54e9a0e6b51c0e444c5add92febbcb0657 Mon Sep 17 00:00:00 2001 From: Christos Zoulas Date: Sat, 26 Jan 2008 18:45:16 +0000 Subject: [PATCH] reduce readonly data. --- ChangeLog | 4 ++++ magic/Magdir/audio | 6 +++--- magic/Makefile.in | 2 ++ src/apprentice.c | 24 ++++++++++++------------ src/ascmagic.c | 4 ++-- src/compress.c | 8 ++++---- src/is_tar.c | 4 ++-- src/names.h | 18 ++++++++---------- src/readelf.c | 8 ++++---- 9 files changed, 41 insertions(+), 37 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2beffb0c..8ecc90d1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2007-01-26 13:45 Christos Zoulas + + * reduce writable data from Diego "Flameeyes" Petten + 2007-12-28 15:06 Christos Zoulas * strtof detection diff --git a/magic/Magdir/audio b/magic/Magdir/audio index 511da1dc..18b47a62 100644 --- a/magic/Magdir/audio +++ b/magic/Magdir/audio @@ -221,9 +221,9 @@ # SGI SoundTrack 0 string _SGI_SoundTrack SGI SoundTrack project file # ID3 version 2 tags -0 string ID3 Audio file with ID3 version 2 ->3 ubyte <0xff \b%d. ->4 ubyte <0xff \b%d tag +0 string ID3 Audio file with ID3 version 2. +>3 ubyte <0xff \b%d +#>4 ubyte <0xff \b%d tag >2584 string fLaC \b, FLAC encoding >>2588 byte&0x7f >0 \b, unknown version >>2588 byte&0x7f 0 \b diff --git a/magic/Makefile.in b/magic/Makefile.in index ba2ef9df..193bea89 100644 --- a/magic/Makefile.in +++ b/magic/Makefile.in @@ -263,6 +263,7 @@ Magdir/maple \ Magdir/mathematica \ Magdir/matroska \ Magdir/mcrypt \ +Magdir/mercurial \ Magdir/mime \ Magdir/mips \ Magdir/mirage \ @@ -352,6 +353,7 @@ Magdir/vxl \ Magdir/wordprocessors \ Magdir/xdelta \ Magdir/xenix \ +Magdir/xilinx \ Magdir/xo65 \ Magdir/xwindows \ Magdir/zilog \ diff --git a/src/apprentice.c b/src/apprentice.c index 24223c28..0dd5a531 100644 --- a/src/apprentice.c +++ b/src/apprentice.c @@ -47,7 +47,7 @@ #endif #ifndef lint -FILE_RCSID("@(#)$File: apprentice.c,v 1.108 2007/12/27 16:35:58 christos Exp $") +FILE_RCSID("@(#)$File: apprentice.c,v 1.109 2007/12/27 20:52:36 christos Exp $") #endif /* lint */ #define EATAB {while (isascii((unsigned char) *l) && \ @@ -151,13 +151,13 @@ main(int argc, char *argv[]) #endif /* COMPILE_ONLY */ static const struct type_tbl_s { - const char *name; + const char name[16]; const size_t len; const int type; const int format; } type_tbl[] = { # define XX(s) s, (sizeof(s) - 1) -# define XX_NULL NULL, 0 +# define XX_NULL "", 0 { XX("byte"), FILE_BYTE, FILE_FMT_NUM }, { XX("short"), FILE_SHORT, FILE_FMT_NUM }, { XX("default"), FILE_DEFAULT, FILE_FMT_STR }, @@ -206,7 +206,7 @@ get_type(const char *l, const char **t) { const struct type_tbl_s *p; - for (p = type_tbl; p->name; p++) { + for (p = type_tbl; p->len; p++) { if (strncmp(l, p->name, p->len) == 0) { if (t) *t = l + p->len; @@ -226,7 +226,7 @@ init_file_tables(void) return; done++; - for (p = type_tbl; p->name; p++) { + for (p = type_tbl; p->len; p++) { assert(p->type < FILE_NAMES_SIZE); file_names[p->type] = p->name; file_formats[p->type] = p->format; @@ -771,19 +771,19 @@ get_op(char c) private int get_cond(const char *l, const char **t) { - static struct cond_tbl_s { - const char *name; - const size_t len; - const int cond; + static const struct cond_tbl_s { + char name[8]; + size_t len; + int cond; } cond_tbl[] = { { "if", 2, COND_IF }, { "elif", 4, COND_ELIF }, { "else", 4, COND_ELSE }, - { NULL, 0, COND_NONE }, + { "", 0, COND_NONE }, }; - struct cond_tbl_s *p; + const struct cond_tbl_s *p; - for (p = cond_tbl; p->name; p++) { + for (p = cond_tbl; p->len; p++) { if (strncmp(l, p->name, p->len) == 0 && isspace((unsigned char)l[p->len])) { if (t) diff --git a/src/ascmagic.c b/src/ascmagic.c index b1d9d796..ab224ac8 100644 --- a/src/ascmagic.c +++ b/src/ascmagic.c @@ -49,7 +49,7 @@ #include "names.h" #ifndef lint -FILE_RCSID("@(#)$File: ascmagic.c,v 1.52 2007/10/17 19:33:31 christos Exp $") +FILE_RCSID("@(#)$File: ascmagic.c,v 1.53 2007/10/29 00:54:08 christos Exp $") #endif /* lint */ typedef unsigned long unichar; @@ -74,7 +74,7 @@ file_ascmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes) unsigned char *nbuf = NULL; unichar *ubuf = NULL; size_t ulen; - struct names *p; + const struct names *p; int rv = -1; int mime = ms->flags & MAGIC_MIME; diff --git a/src/compress.c b/src/compress.c index a785072e..9eaca906 100644 --- a/src/compress.c +++ b/src/compress.c @@ -56,13 +56,13 @@ #ifndef lint -FILE_RCSID("@(#)$File: compress.c,v 1.53 2007/10/17 19:33:31 christos Exp $") +FILE_RCSID("@(#)$File: compress.c,v 1.54 2007/12/02 00:28:10 christos Exp $") #endif -private struct { - const char *magic; +private const struct { + const char magic[8]; size_t maglen; - const char *const argv[3]; + const char *argv[3]; int silent; } compr[] = { { "\037\235", 2, { "gzip", "-cdq", NULL }, 1 }, /* compressed */ diff --git a/src/is_tar.c b/src/is_tar.c index cbaba63c..ff57e4d2 100644 --- a/src/is_tar.c +++ b/src/is_tar.c @@ -45,7 +45,7 @@ #include "tar.h" #ifndef lint -FILE_RCSID("@(#)$File: is_tar.c,v 1.28 2007/08/19 03:45:08 christos Exp $") +FILE_RCSID("@(#)$File: is_tar.c,v 1.29 2007/10/17 19:33:31 christos Exp $") #endif #define isodigit(c) ( ((c) >= '0') && ((c) <= '7') ) @@ -53,7 +53,7 @@ FILE_RCSID("@(#)$File: is_tar.c,v 1.28 2007/08/19 03:45:08 christos Exp $") private int is_tar(const unsigned char *, size_t); private int from_oct(int, const char *); /* Decode octal number */ -static const char *tartype[] = { +static const char tartype[][32] = { "tar archive", "POSIX tar archive", "POSIX tar archive (GNU)", diff --git a/src/names.h b/src/names.h index 2027ebd9..c7cd38e0 100644 --- a/src/names.h +++ b/src/names.h @@ -32,7 +32,7 @@ * appear at fixed offsets into the file. Don't make HOWMANY * too high unless you have a very fast CPU. * - * $File: names.h,v 1.28 2007/10/29 00:54:08 christos Exp $ + * $File: names.h,v 1.29 2007/12/27 20:30:35 christos Exp $ */ /* @@ -57,8 +57,8 @@ #define L_PO 13 /* PO */ static const struct { - const char *human; - const char *mime; + char human[48]; + char mime[16]; } types[] = { { "C program", "text/x-c", }, { "C++ program", "text/x-c++" }, @@ -74,8 +74,7 @@ static const struct { { "BCPL program", "text/x-bcpl" }, { "M4 macro language pre-processor", "text/x-m4" }, { "PO (gettext message catalogue)", "text/x-po" }, - { "cannot happen error on names.h/types", "error/x-error" }, - { 0, 0} + { "cannot happen error on names.h/types", "error/x-error" } }; /* @@ -114,8 +113,8 @@ static const struct { * as Java, as it comes after "the" and "The". Perhaps we need a fancier * heuristic to identify Java? */ -static struct names { - const char *name; +static const struct names { + char name[14]; short type; } names[] = { /* These must be sorted by eye for optimal hit rate */ @@ -180,7 +179,6 @@ static struct names { {"