Browse code

realign structs see bb#474

git-svn: trunk@3537

aCaB authored on 2008/01/24 22:24:02
Showing 22 changed files
... ...
@@ -1,3 +1,7 @@
1
+Thu Jan 24 15:01:03 CET 2008 (acab)
2
+-----------------------------------
3
+ * libclamav: realign structs (related to bb#474)
4
+
1 5
 Wed Jan 23 21:52:06 EET 2008 (edwin)
2 6
 ------------------------------------
3 7
  * libclamav/entconv.c: optimize u16_normalize, encode as hex entities
... ...
@@ -35,8 +35,6 @@ struct DICT_HELPER {
35 35
 struct ASPK {
36 36
   uint32_t bitpos;
37 37
   uint32_t hash;
38
-  uint8_t array1[19];
39
-  uint8_t array2[758];
40 38
   uint32_t init_array[58];
41 39
   struct DICT_HELPER dict_helper[4];
42 40
   uint8_t *input;
... ...
@@ -45,6 +43,8 @@ struct ASPK {
45 45
   uint32_t decarray3[4][24];
46 46
   uint32_t decarray4[4][24];
47 47
   int dict_ok;
48
+  uint8_t array2[758];
49
+  uint8_t array1[19];
48 50
 };
49 51
 
50 52
 
... ...
@@ -78,9 +78,9 @@ static unsigned int u2a(uint8_t *dest, unsigned int len) {
78 78
 *********************/
79 79
 
80 80
 struct MT {
81
-  uint32_t mt[624];
82
-  uint32_t items;
83 81
   uint32_t *next;
82
+  uint32_t items;
83
+  uint32_t mt[624];
84 84
 };
85 85
 
86 86
 static uint8_t MT_getnext(struct MT *MT) {
... ...
@@ -56,10 +56,10 @@ typedef	struct fileblob {
56 56
 			 * email, not the full path name of the temporary file
57 57
 			 */
58 58
 	char	*fullname;	/* full pathname of the file */
59
+	cli_ctx	*ctx;	/* When set we can scan the blob, otherwise NULL */
60
+	unsigned	long	bytes_scanned;
59 61
 	unsigned	int	isNotEmpty : 1;
60 62
 	unsigned	int	isInfected : 1;
61
-	unsigned	long	bytes_scanned;
62
-	cli_ctx	*ctx;	/* When set we can scan the blob, otherwise NULL */
63 63
 } fileblob;
64 64
 
65 65
 fileblob	*fileblobCreate(void);
... ...
@@ -26,30 +26,29 @@
26 26
 #define CAB_INPUTMAX (CAB_BLOCKMAX + 6144)
27 27
 
28 28
 struct cab_archive {
29
+    struct cab_folder *folders;
30
+    struct cab_file *files;
29 31
     uint32_t length;
30 32
     uint16_t nfolders;
31 33
     uint16_t nfiles;
32 34
     uint16_t flags;
33 35
     uint16_t reshdr;
34 36
     uint8_t resdata;
35
-    struct cab_folder *folders;
36
-    struct cab_file *files;
37 37
 };
38 38
 
39 39
 struct cab_state {
40 40
     unsigned char *pt, *end;
41
+    void *stream;
41 42
     unsigned char block[CAB_INPUTMAX];
42 43
     uint16_t blklen;
43 44
     uint16_t outlen;
44
-    void *stream;
45 45
     uint16_t blknum;
46 46
 };
47 47
 
48 48
 struct cab_file {
49
-    uint32_t length;
50
-    uint16_t attribs;
51 49
     off_t offset;
52 50
     char *name;
51
+    uint32_t length;
53 52
     int error;
54 53
     int fd;
55 54
     int ofd;
... ...
@@ -57,14 +56,15 @@ struct cab_file {
57 57
     struct cab_file *next;
58 58
     struct cab_archive *cab;
59 59
     struct cab_state *state;
60
+    uint16_t attribs;
60 61
 };
61 62
 
62 63
 struct cab_folder {
63
-    uint16_t cmethod;
64
-    uint16_t nblocks;
65 64
     struct cab_archive *cab;
66 65
     off_t offset;
67 66
     struct cab_folder *next;
67
+    uint16_t cmethod;
68
+    uint16_t nblocks;
68 69
 };
69 70
 
70 71
 int cab_open(int fd, off_t offset, struct cab_archive *cab);
... ...
@@ -93,6 +93,8 @@ typedef struct chm_sys_entry_tag
93 93
 } chm_sys_entry_t;
94 94
 
95 95
 typedef struct chm_metadata_tag {
96
+	uint64_t file_length;
97
+	uint64_t file_offset;
96 98
 	chm_sys_entry_t sys_control;
97 99
 	chm_sys_entry_t sys_content;
98 100
 	chm_sys_entry_t sys_reset;
... ...
@@ -108,8 +110,6 @@ typedef struct chm_metadata_tag {
108 108
 	char *chunk_current;
109 109
 	char *chunk_end;
110 110
 	uint16_t chunk_entries;
111
-	uint64_t file_length;
112
-	uint64_t file_offset;
113 111
 } chm_metadata_t;
114 112
 
115 113
 int chm_unpack(int fd, const char *dirname);
... ...
@@ -53,10 +53,6 @@ struct entity_conv {
53 53
 	char* encoding;
54 54
 	enum encoding_priority priority;
55 55
 	enum encodings encoding_symbolic;
56
-	uint8_t has_bom;
57
-	uint8_t enc_bytes;
58
-	uint8_t  bom_cnt;
59
-	unsigned char bom[4];
60 56
 	size_t buffer_size;
61 57
 	void* iconv_struct;
62 58
 	unsigned char entity_buff[MAX_ENTITY_SIZE+2];
... ...
@@ -65,6 +61,10 @@ struct entity_conv {
65 65
 	m_area_t norm_area;
66 66
 	int      linemode;/* TODO:set */
67 67
 	int      linemode_processed;
68
+	unsigned char bom[4];
69
+	uint8_t has_bom;
70
+	uint8_t enc_bytes;
71
+	uint8_t  bom_cnt;
68 72
 };
69 73
 
70 74
 int init_entity_converter(struct entity_conv* conv, size_t buffer_size);
... ...
@@ -36,10 +36,10 @@ struct cli_exe_section {
36 36
 };
37 37
 
38 38
 struct cli_exe_info {
39
+    struct cli_exe_section *section;
40
+    off_t offset;
39 41
     uint32_t ep;
40 42
     uint16_t nsections;
41
-    off_t offset;
42
-    struct cli_exe_section *section;
43 43
 };
44 44
 
45 45
 #endif
... ...
@@ -60,10 +60,10 @@ struct xplstate {
60 60
   uint16_t backbytes;
61 61
   uint16_t backsize;
62 62
   uint8_t window[8192];
63
+  enum XPL_STATE state;
63 64
   uint8_t bits;
64 65
   uint8_t largewin;
65 66
   uint8_t litcodes;
66
-  enum XPL_STATE state;
67 67
 };
68 68
 
69 69
 int explode_init(struct xplstate *, uint16_t);
... ...
@@ -76,17 +76,17 @@ struct internal_state;
76 76
 
77 77
 typedef struct z_stream64_s {
78 78
     uint8_t		*next_in;  /* next input byte */
79
-    unsigned int	avail_in;  /* number of bytes available at next_in */
80 79
     unsigned long	total_in;  /* total nb of input bytes read so far */
80
+    unsigned int	avail_in;  /* number of bytes available at next_in */
81 81
 
82
-    uint8_t		*next_out; /* next output byte should be put there */
83 82
     unsigned int	avail_out; /* remaining free space at next_out */
83
+    uint8_t		*next_out; /* next output byte should be put there */
84 84
     unsigned long	total_out; /* total nb of bytes output so far */
85 85
 
86 86
     struct internal_state FAR *state; /* not visible by applications */
87 87
 
88
-    int     data_type;  /* best guess about the data type: binary or text */
89 88
     unsigned long   adler;      /* adler32 value of the uncompressed data */
89
+    int     data_type;  /* best guess about the data type: binary or text */
90 90
 } z_stream64;
91 91
 
92 92
 typedef z_stream64 FAR *z_stream64p;
... ...
@@ -39,19 +39,19 @@
39 39
 #define CLI_MATCH_NIBBLE_LOW	0x0400
40 40
 
41 41
 struct cli_matcher {
42
-    uint16_t maxpatlen;
43
-    uint8_t ac_only;
44
-
45 42
     /* Extended Boyer-Moore */
46 43
     uint8_t *bm_shift;
47 44
     struct cli_bm_patt **bm_suffix;
48 45
     uint32_t *soff, soff_len; /* for PE section sigs */
49 46
 
50 47
     /* Extended Aho-Corasick */
51
-    uint8_t ac_mindepth, ac_maxdepth;
48
+    uint32_t ac_partsigs, ac_nodes, ac_patterns;
52 49
     struct cli_ac_node *ac_root, **ac_nodetable;
53 50
     struct cli_ac_patt **ac_pattable;
54
-    uint32_t ac_partsigs, ac_nodes, ac_patterns;
51
+    uint8_t ac_mindepth, ac_maxdepth;
52
+
53
+    uint16_t maxpatlen;
54
+    uint8_t ac_only;
55 55
 };
56 56
 
57 57
 struct cli_meta_node {
... ...
@@ -213,10 +213,10 @@ typedef	unsigned	int	in_addr_t;
213 213
 
214 214
 typedef	struct	mbox_ctx {
215 215
 	const	char	*dir;
216
-	unsigned	int	files;	/* number of files extracted */
217 216
 	const	table_t	*rfc821Table;
218 217
 	const	table_t	*subtypeTable;
219 218
 	cli_ctx	*ctx;
219
+	unsigned	int	files;	/* number of files extracted */
220 220
 } mbox_ctx;
221 221
 
222 222
 static	int	cli_parse_mbox(const char *dir, int desc, cli_ctx *ctx);
... ...
@@ -22,19 +22,16 @@
22 22
 
23 23
 /* The contents could change, ONLY access in message.c */
24 24
 typedef struct message {
25
-	mime_type	mimeType;
26 25
 	encoding_type	*encodingTypes;
26
+	mime_type	mimeType;
27 27
 	int	numberOfEncTypes;	/* size of encodingTypes */
28 28
 	char	*mimeSubtype;
29
-	int	numberOfArguments;	/* count of mimeArguments */
30 29
 	char	**mimeArguments;
31 30
 	char	*mimeDispositionType;	/* probably attachment */
32 31
 	text	*body_first, *body_last;
33 32
 	cli_ctx	*ctx;	/* When set we can scan the message, otherwise NULL */
34
-
35
-	char	base64_1, base64_2, base64_3;
33
+	int	numberOfArguments;	/* count of mimeArguments */
36 34
 	int	base64chars;
37
-	unsigned	int	isInfected : 1;
38 35
 
39 36
 	/*
40 37
 	 * Markers for the start of various non MIME messages that could
... ...
@@ -45,6 +42,10 @@ typedef struct message {
45 45
 	text	*yenc;		/* start of a yEnc message */
46 46
 	text	*encoding;	/* is the non MIME message encoded? */
47 47
 	const text	*dedupedThisFar;
48
+
49
+	char	base64_1, base64_2, base64_3;
50
+	unsigned	int	isInfected : 1;
51
+
48 52
 } message;
49 53
 
50 54
 message	*messageCreate(void);
... ...
@@ -57,9 +57,6 @@
57 57
 struct mszip_stream {
58 58
   int fd;		    /* input file descriptor */
59 59
   int ofd;                  /* output file descriptor */
60
-  unsigned char wflag;	    /* write flag */
61
-
62
-  unsigned int window_posn;             /* offset within window  */
63 60
 
64 61
   /* inflate() will call this whenever the window should be emptied. */
65 62
   int (*flush_window)(struct mszip_stream *, unsigned int);
... ...
@@ -70,6 +67,8 @@ struct mszip_stream {
70 70
   unsigned char *inbuf, *i_ptr, *i_end, *o_ptr, *o_end;
71 71
   unsigned int bit_buffer, bits_left, inbuf_size;
72 72
 
73
+  unsigned int window_posn;             /* offset within window  */
74
+
73 75
   /* huffman code lengths */
74 76
   unsigned char  LITERAL_len[MSZIP_LITERAL_MAXSYMBOLS];
75 77
   unsigned char  DISTANCE_len[MSZIP_DISTANCE_MAXSYMBOLS];
... ...
@@ -84,6 +83,9 @@ struct mszip_stream {
84 84
   /* cabinet related stuff */
85 85
   struct cab_file *file;
86 86
   int (*read)(struct cab_file *, unsigned char *, int);
87
+
88
+  unsigned char wflag;	    /* write flag */
89
+
87 90
 };
88 91
 
89 92
 struct mszip_stream *mszip_init(int fd,
... ...
@@ -118,7 +120,6 @@ struct qtm_model {
118 118
 struct qtm_stream {
119 119
   int fd;                   /* input file descriptor */
120 120
   int ofd;                  /* output file descriptor */
121
-  unsigned char wflag;	    /* write flag */
122 121
 
123 122
   unsigned char *window;          /* decoding window                         */
124 123
   unsigned int window_size;       /* window size                             */
... ...
@@ -127,14 +128,10 @@ struct qtm_stream {
127 127
 
128 128
   unsigned short H, L, C;         /* high/low/current: arith coding state    */
129 129
   unsigned char header_read;      /* have we started decoding a new frame?   */
130
+  unsigned char wflag;	    /* write flag */
130 131
 
131 132
   int error;
132 133
 
133
-  /* I/O buffers */
134
-  unsigned char *inbuf, *i_ptr, *i_end, *o_ptr, *o_end;
135
-  unsigned int  bit_buffer, inbuf_size;
136
-  unsigned char bits_left;
137
-
138 134
   /* data tables */
139 135
   unsigned int  position_base[42];
140 136
   unsigned char extra_bits[42], length_base[27], length_extra[27];
... ...
@@ -165,10 +162,18 @@ struct qtm_stream {
165 165
   struct qtm_modelsym m6sym[42 + 1], m6lsym[27 + 1];
166 166
   struct qtm_modelsym m7sym[7 + 1];
167 167
 
168
+  /* I/O buffers - 1*/
169
+  unsigned int  bit_buffer;
170
+
168 171
   /* cabinet related stuff */
169 172
   struct cab_file *file;
170 173
   int (*read)(struct cab_file *, unsigned char *, int);
171 174
 
175
+  /* I/O buffers - 2*/
176
+  unsigned char *inbuf, *i_ptr, *i_end, *o_ptr, *o_end;
177
+  unsigned int  inbuf_size;
178
+  unsigned char bits_left;
179
+
172 180
 };
173 181
 
174 182
 extern struct qtm_stream *qtm_init(int fd,
... ...
@@ -215,7 +220,6 @@ void qtm_free(struct qtm_stream *qtm);
215 215
 struct lzx_stream {
216 216
   int fd;			  /* input file descriptor                   */
217 217
   int ofd;			  /* output file descriptor                  */
218
-  unsigned char wflag;		  /* write flag */
219 218
 
220 219
   off_t   offset;                 /* number of bytes actually output         */
221 220
   off_t   length;                 /* overall decompressed length of stream   */
... ...
@@ -238,7 +242,6 @@ struct lzx_stream {
238 238
   unsigned char  block_type;      /* type of the current block               */
239 239
   unsigned char  header_read;     /* have we started decoding at all yet?    */
240 240
   unsigned char  posn_slots;      /* how many posn slots in stream?          */
241
-  unsigned char  input_end;       /* have we reached the end of input?       */
242 241
 
243 242
   int error;
244 243
 
... ...
@@ -261,16 +264,20 @@ struct lzx_stream {
261 261
 				(LZX_LENGTH_MAXSYMBOLS * 2)];
262 262
   unsigned short ALIGNED_table [(1 << LZX_ALIGNED_TABLEBITS) +
263 263
 				(LZX_ALIGNED_MAXSYMBOLS * 2)];
264
-
265
-  unsigned int  position_base[51];
266
-  unsigned char extra_bits[51];
264
+  unsigned char  input_end;       /* have we reached the end of input?       */
265
+  unsigned char wflag;		  /* write flag */
267 266
 
268 267
   /* this is used purely for doing the intel E8 transform */
269 268
   unsigned char  e8_buf[LZX_FRAME_SIZE];
270 269
 
270
+  unsigned int  position_base[51];
271
+
271 272
   /* cabinet related stuff */
272 273
   struct cab_file *file;
273 274
   int (*read)(struct cab_file *, unsigned char *, int);
275
+
276
+  unsigned char extra_bits[51];
277
+
274 278
 };
275 279
 
276 280
 struct lzx_stream *lzx_init(int fd,
... ...
@@ -99,10 +99,10 @@ typedef struct ole2_header_tag
99 99
 	/* must take account of the size of variables below here when
100 100
 	   reading the header */
101 101
 	int32_t sbat_root_start __attribute__ ((packed));
102
+	uint32_t max_block_no;
102 103
 	unsigned char *m_area;
103 104
 	off_t m_length;
104 105
 	bitset_t *bitset;
105
-	uint32_t max_block_no;
106 106
 } ole2_header_t;
107 107
 
108 108
 typedef struct property_tag
... ...
@@ -124,13 +124,13 @@ typedef unsigned char cat_t;
124 124
  * main compiled-expression structure
125 125
  */
126 126
 struct re_guts {
127
-	int magic;
128 127
 #		define	MAGIC2	((('R'^0200)<<8)|'E')
129 128
 	sop *strip;		/* malloced area for strip */
130
-	int csetsize;		/* number of bits in a cset vector */
131
-	int ncsets;		/* number of csets in use */
132 129
 	cset *sets;		/* -> cset [ncsets] */
133 130
 	uch *setbits;		/* -> uch[csetsize][ncsets/CHAR_BIT] */
131
+	int magic;
132
+	int csetsize;		/* number of bits in a cset vector */
133
+	int ncsets;		/* number of csets in use */
134 134
 	int cflags;		/* copy of cli_regcomp() cflags argument */
135 135
 	sopno nstates;		/* = number of sops */
136 136
 	sopno firststate;	/* the initial OEND (normally 0) */
... ...
@@ -145,8 +145,8 @@ struct re_guts {
145 145
 	cat_t *categories;	/* ->catspace[-CHAR_MIN] */
146 146
 	char *must;		/* match must contain this string */
147 147
 	int mlen;		/* length of must */
148
-	size_t nsub;		/* copy of re_nsub */
149 148
 	int backrefs;		/* does it use back references? */
149
+	size_t nsub;		/* copy of re_nsub */
150 150
 	sopno nplus;		/* how deep does it nest +s? */
151 151
 	/* catspace must be last */
152 152
 	cat_t catspace[1];	/* actually [NC] */
... ...
@@ -22,8 +22,8 @@
22 22
  */
23 23
 typedef	struct	tableEntry {
24 24
 	char	*key;
25
-	int	value;
26 25
 	struct	tableEntry	*next;
26
+	int	value;
27 27
 } tableEntry;
28 28
 
29 29
 typedef struct table {
... ...
@@ -146,11 +146,10 @@ typedef struct arj_file_hdr_tag {
146 146
 #endif
147 147
 
148 148
 typedef struct arj_decode_tag {
149
-	int fd;
150 149
 	unsigned char *text;
150
+	int fd;
151 151
 	uint16_t blocksize;
152 152
 	uint16_t bit_buf;
153
-	unsigned char sub_bit_buf;
154 153
 	int bit_count;
155 154
 	uint32_t comp_size;
156 155
 	int16_t getlen, getbuf;
... ...
@@ -159,6 +158,7 @@ typedef struct arj_decode_tag {
159 159
 	unsigned char c_len[NC];
160 160
 	uint16_t c_table[CTABLESIZE];
161 161
 	unsigned char pt_len[NPT];
162
+	unsigned char sub_bit_buf;
162 163
 	uint16_t pt_table[PTABLESIZE];
163 164
 } arj_decode_t;
164 165
 
... ...
@@ -22,12 +22,12 @@
22 22
 #define __UNARJ_H
23 23
 
24 24
 typedef struct arj_metadata_tag {
25
+	char *filename;
25 26
 	uint32_t comp_size;
26 27
 	uint32_t orig_size;
27
-	uint8_t method;
28
-	char *filename;
29 28
 	int encrypted;
30 29
 	int ofd;
30
+	uint8_t method;
31 31
 } arj_metadata_t;
32 32
 
33 33
 int cli_unarj_open(int fd, const char *dirname);
... ...
@@ -29,8 +29,8 @@ struct UNSP {
29 29
   uint32_t oldval;
30 30
   int error;
31 31
   /* the following are not in the original structure */
32
-  char *table;
33 32
   uint32_t tablesz;
33
+  char *table;
34 34
 };
35 35
 
36 36
 uint32_t unspack(char *, char *, cli_ctx *, uint32_t, uint32_t, uint32_t, int);
... ...
@@ -851,14 +851,14 @@ typedef struct {
851 851
 } mso_fib_t;
852 852
 
853 853
 typedef struct macro_entry_tag {
854
-	unsigned char key;
855 854
 	uint32_t len;
856 855
 	uint32_t offset;
856
+	unsigned char key;
857 857
 } macro_entry_t;
858 858
 
859 859
 typedef struct macro_info_tag {
860
-	uint16_t count;
861 860
 	struct macro_entry_tag *entries;
861
+	uint16_t count;
862 862
 } macro_info_t;
863 863
 
864 864
 static int
... ...
@@ -25,12 +25,12 @@
25 25
 #include "cltypes.h"
26 26
 
27 27
 typedef struct vba_project_tag {
28
-	int count;
29 28
 	char **name;
30 29
 	uint32_t *offset;
31 30
 	uint32_t *length;	/* for Word 6 macros */
32 31
 	unsigned char *key;	/* for Word 6 macros */
33 32
 	char *dir;
33
+	int count;
34 34
 } vba_project_t;
35 35
 
36 36
 vba_project_t	*cli_vba_readdir(const char *dir);