Browse code

avoid holes in data-structures due to alignment.

git-svn: trunk@3459

Török Edvin authored on 2007/12/28 21:30:23
Showing 5 changed files
... ...
@@ -1,3 +1,8 @@
1
+Fri Dec 28 13:53:33 EET 2007 (edwin)
2
+------------------------------------
3
+  * libclamav/phishcheck.h, regex_list.[ch], rtf.c:
4
+	avoid holes in data-structures due to alignment.
5
+
1 6
 Thu Dec 27 14:21:52 GMT 2007 (trog)
2 7
 -----------------------------------
3 8
   * libclamav/chmunpack.c: fix bb#740
... ...
@@ -36,9 +36,9 @@ enum phish_status {CL_PHISH_NODECISION=0, CL_PHISH_CLEAN=CL_PHISH_BASE,
36 36
 #define CL_PHISH_ALL_CHECKS (CLEANUP_URL|CHECK_SSL|CHECK_CLOAKING|CHECK_IMG_URL)
37 37
 
38 38
 struct string {
39
-	int refcount;
40 39
 	struct string* ref;
41 40
 	char* data;
41
+	int refcount;
42 42
 };
43 43
 
44 44
 struct phishcheck {
... ...
@@ -77,15 +77,15 @@ typedef unsigned char* char_bitmap_p;
77 77
  */
78 78
 struct tree_node {
79 79
 	struct tree_node* next;/* next regex/complex sibling, or parent, if no more siblings , can't be NULL except for root node*/
80
-	unsigned char c;
81
-	enum token_op_t op;
82
-	char alternatives;/* number of (non-regex) children of node, i.e. sizeof(children)*/
83
-	char listend;/* no more siblings, next pointer is pointer to parent*/
84 80
 	union {
85 81
 		struct tree_node** children;/* alternatives nr. of children, followed by (a null pointer terminated) regex leaf node pointers) */
86 82
 		char_bitmap_p* bitmap;
87 83
 		struct leaf_info*  leaf;
88 84
 	} u;
85
+	enum token_op_t op;
86
+	unsigned char c;
87
+	char alternatives;/* number of (non-regex) children of node, i.e. sizeof(children)*/
88
+	char listend;/* no more siblings, next pointer is pointer to parent*/
89 89
 };
90 90
 
91 91
 struct leaf_info {
... ...
@@ -45,12 +45,12 @@ struct regex_matcher {
45 45
 	struct cli_matcher* root_hosts;
46 46
 	struct tree_node* root_regex;
47 47
 	struct tree_node* root_regex_hostonly; 
48
+	struct node_stack node_stack;
49
+	struct node_stack node_stack_alt;
48 50
 	size_t root_hosts_cnt;
49 51
 	int list_inited;
50 52
 	int list_loaded;
51 53
 	int list_built;
52
-	struct node_stack node_stack;
53
-	struct node_stack node_stack_alt;
54 54
 };
55 55
 
56 56
 int regex_list_match(struct regex_matcher* matcher, char* real_url,const char* display_url,const struct pre_fixup_info* pre_fixup, int hostOnly,const char** info,int is_whitelist);
... ...
@@ -50,6 +50,10 @@ typedef int (*rtf_callback_process)(struct rtf_state*, const unsigned char* data
50 50
 typedef int (*rtf_callback_end)(struct rtf_state*, cli_ctx*);
51 51
 
52 52
 struct rtf_state {
53
+	rtf_callback_begin cb_begin;/* must be non-null if you want cb_process, and cb_end to be called, also it must change cb_data to non-null */
54
+	rtf_callback_process cb_process;
55
+	rtf_callback_end cb_end;
56
+	void* cb_data;/* data set up by cb_begin, used by cb_process, and cleaned up by cb_end. typically state data */
53 57
 	size_t default_elements;
54 58
 	size_t controlword_cnt;
55 59
 	ssize_t controlword_param;
... ...
@@ -57,14 +61,10 @@ struct rtf_state {
57 57
 	int  controlword_param_sign;
58 58
 	int  encounteredTopLevel;/* encountered top-level control words that we care about */
59 59
 	char controlword[33];
60
-	rtf_callback_begin cb_begin;/* must be non-null if you want cb_process, and cb_end to be called, also it must change cb_data to non-null */
61
-	rtf_callback_process cb_process;
62
-	rtf_callback_end cb_end;
63
-	void* cb_data;/* data set up by cb_begin, used by cb_process, and cleaned up by cb_end. typically state data */
64 60
 };
65 61
 
66 62
 static const struct rtf_state base_state = {
67
-	0,0,0,PARSE_MAIN,0,0,"                              ",NULL,NULL,NULL,NULL
63
+	NULL,NULL,NULL,NULL,0,0,0,PARSE_MAIN,0,0,"                              "
68 64
 };
69 65
 
70 66
 struct stack {