Browse code

avoid holes in often used data structures (bb#748);

git-svn: trunk@3495

Tomasz Kojm authored on 2008/01/11 04:37:27
Showing 5 changed files
... ...
@@ -1,3 +1,8 @@
1
+Thu Jan 10 20:08:58 CET 2008 (tk)
2
+---------------------------------
3
+  * libclamav: avoid holes in often used data structures (bb#748);
4
+	       thanks to Edwin
5
+
1 6
 Thu Jan 10 18:33:26 CET 2008 (tk)
2 7
 ---------------------------------
3 8
   * shared/misc.c: don't pass --rsrc flag to ditto (bb#380)
... ...
@@ -83,16 +83,16 @@ struct cli_ftype {
83 83
     cli_file_t type;
84 84
     uint32_t offset;
85 85
     unsigned char *magic;
86
-    uint16_t length;
87 86
     char *tname;
88 87
     struct cli_ftype *next;
88
+    uint16_t length;
89 89
 };
90 90
 
91 91
 struct cli_matched_type {
92
-    cli_file_t type;
92
+    struct cli_matched_type *next;
93 93
     off_t offset;
94
+    cli_file_t type;
94 95
     unsigned short cnt;
95
-    struct cli_matched_type *next;
96 96
 };
97 97
 
98 98
 cli_file_t cli_ftcode(const char *name);
... ...
@@ -30,34 +30,34 @@
30 30
 extern uint8_t cli_ac_mindepth, cli_ac_maxdepth;
31 31
 
32 32
 struct cli_ac_data {
33
-    uint32_t partsigs;
34 33
     int32_t ***offmatrix;
34
+    uint32_t partsigs;
35 35
 };
36 36
 
37 37
 struct cli_ac_alt {
38
-    uint8_t chmode;
39 38
     unsigned char *str;
40
-    uint16_t len, num;
41 39
     struct cli_ac_alt *next;
40
+    uint16_t len, num;
41
+    uint8_t chmode;
42 42
 };
43 43
 
44 44
 struct cli_ac_patt {
45 45
     uint16_t *pattern, *prefix, length, prefix_length;
46
-    uint8_t depth;
47 46
     uint32_t mindist, maxdist;
48
-    char *virname, *offset;
49 47
     uint32_t sigid;
48
+    char *virname, *offset;
50 49
     uint16_t parts, partno, alt, alt_pattern;
51 50
     struct cli_ac_alt **alttable;
51
+    struct cli_ac_patt *next, *next_same;
52
+    uint8_t depth;
52 53
     uint8_t target;
53 54
     uint16_t type;
54
-    struct cli_ac_patt *next, *next_same;
55 55
 };
56 56
 
57 57
 struct cli_ac_node {
58
-    uint8_t leaf, final;
59 58
     struct cli_ac_patt *list;
60 59
     struct cli_ac_node **trans, *fail;
60
+    uint8_t leaf, final;
61 61
 };
62 62
 
63 63
 #include "matcher.h"
... ...
@@ -25,11 +25,11 @@
25 25
 
26 26
 struct cli_bm_patt {
27 27
     unsigned char *pattern, *prefix;
28
-    uint16_t length, prefix_length;
29 28
     char *virname, *offset;
30
-    uint8_t target;
31 29
     struct cli_bm_patt *next;
30
+    uint16_t length, prefix_length;
32 31
     uint16_t cnt;
32
+    uint8_t target;
33 33
 };
34 34
 
35 35
 int cli_bm_addpatt(struct cli_matcher *root, struct cli_bm_patt *pattern);
... ...
@@ -55,10 +55,10 @@ struct cli_matcher {
55 55
 };
56 56
 
57 57
 struct cli_meta_node {
58
-    int csize, size, method;
59
-    unsigned int crc32, fileno, encrypted, maxdepth;
60 58
     char *filename, *virname;
61 59
     struct cli_meta_node *next;
60
+    int csize, size, method;
61
+    unsigned int crc32, fileno, encrypted, maxdepth;
62 62
 };
63 63
 
64 64
 #define CL_TARGET_TABLE_SIZE 7