Browse code

minor code cleanup and bug fix

git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@382 77e5149b-7576-45b1-b177-96237e5ba77b

Trog authored on 2004/03/08 21:30:05
Showing 3 changed files
... ...
@@ -1,3 +1,6 @@
1
+Mon Mar  8 12:37:26 GMT 2004 (trog)
2
+-----------------------------------
3
+  * libclamav: vba_extract.c/ole2_extract.c: minor code cleanup and bug fix
1 4
 Mon Mar  8 10:01:01 GMT 2004 (trog)
2 5
 -----------------------------------
3 6
   * clamd: wrap select()/poll()
... ...
@@ -97,7 +97,7 @@ typedef struct ole2_header_tag
97 97
 	/* must take account of the size of variables below here when
98 98
 	   reading the header */
99 99
 	int32_t sbat_root_start;
100
-} ole2_header_t __attribute__ ((packed));
100
+} __attribute__ ((packed)) ole2_header_t;
101 101
 
102 102
 typedef struct property_tag
103 103
 {
... ...
@@ -110,7 +110,7 @@ typedef struct property_tag
110 110
 	int32_t child;
111 111
 
112 112
 	unsigned char clsid[16];
113
-	uint16_t user_flags;
113
+	uint32_t user_flags;
114 114
 
115 115
 	uint32_t create_lowdate;
116 116
 	uint32_t create_highdate;
... ...
@@ -119,7 +119,7 @@ typedef struct property_tag
119 119
 	int32_t start_block;
120 120
 	int32_t size;
121 121
 	unsigned char reserved[4];
122
-} property_t __attribute__ ((packed));
122
+} __attribute__ ((packed)) property_t;
123 123
 
124 124
 #ifdef HAVE_PRAGMA_PACK
125 125
 #pragma pack()
... ...
@@ -135,10 +135,10 @@ int readn(int fd, void *buff, unsigned int count)
135 135
 {
136 136
 	int retval;
137 137
 	unsigned int todo;
138
-	void *current;
138
+	unsigned char *current;
139 139
 
140 140
 	todo = count;
141
-	current = buff;
141
+	current = (unsigned char *) buff;
142 142
 
143 143
 	do {
144 144
 		retval = read(fd, current, todo);
... ...
@@ -162,10 +162,10 @@ int writen(int fd, void *buff, unsigned int count)
162 162
 {
163 163
 	int retval;
164 164
 	unsigned int todo;
165
-	void *current;
165
+	unsigned char *current;
166 166
 
167 167
 	todo = count;
168
-	current = buff;
168
+	current = (unsigned char *) buff;
169 169
 
170 170
 	do {
171 171
 		retval = write(fd, current, todo);
... ...
@@ -455,7 +455,7 @@ void ole2_read_property_tree(int fd, ole2_header_t *hdr, const char *dir,
455 455
 				prop_block[index].prev = ole2_endian_convert_32(prop_block[index].prev);
456 456
 				prop_block[index].next = ole2_endian_convert_32(prop_block[index].next);
457 457
 				prop_block[index].child = ole2_endian_convert_32(prop_block[index].child);
458
-				prop_block[index].user_flags = ole2_endian_convert_16(prop_block[index].user_flags);
458
+				prop_block[index].user_flags = ole2_endian_convert_32(prop_block[index].user_flags);
459 459
 				prop_block[index].create_lowdate = ole2_endian_convert_32(prop_block[index].create_lowdate);
460 460
 				prop_block[index].create_highdate = ole2_endian_convert_32(prop_block[index].create_highdate);
461 461
 				prop_block[index].mod_lowdate = ole2_endian_convert_32(prop_block[index].mod_lowdate);
... ...
@@ -100,10 +100,10 @@ int vba_readn(int fd, void *buff, unsigned int count)
100 100
 {
101 101
         int retval;
102 102
         unsigned int todo;
103
-        void *current;
103
+        unsigned char *current;
104 104
  
105 105
         todo = count;
106
-        current = buff;
106
+        current = (unsigned char *) buff;
107 107
  
108 108
         do {
109 109
                 retval = read(fd, current, todo);
... ...
@@ -127,11 +127,11 @@ int vba_writen(int fd, void *buff, unsigned int count)
127 127
 {
128 128
         int retval;
129 129
         unsigned int todo;
130
-        void *current;
131
-                                                                                                                                                                          
130
+        unsigned char *current;
131
+
132 132
         todo = count;
133
-        current = buff;
134
-                                                                                                                                                                          
133
+        current = (unsigned char *) buff;
134
+
135 135
         do {
136 136
                 retval = write(fd, current, todo);
137 137
                 if (retval < 0) {
... ...
@@ -140,7 +140,7 @@ int vba_writen(int fd, void *buff, unsigned int count)
140 140
                 todo -= retval;
141 141
                 current += retval;
142 142
         } while (todo > 0);
143
-                                                                                                                                                                          
143
+
144 144
         return count;
145 145
 }
146 146
 
... ...
@@ -148,11 +148,11 @@ char *get_unicode_name(char *name, int size)
148 148
 {
149 149
         int i, j;
150 150
         char *newname;
151
-                                                                                                                                                                          
152
-        if (*name == 0 || size == 0) {
151
+
152
+	 if (*name == 0 || size == 0) {
153 153
                 return NULL;
154 154
         }
155
-                                                                                                                                                                          
155
+
156 156
         newname = (char *) cli_malloc(size*2);
157 157
         if (!newname) {
158 158
                 return NULL;
... ...
@@ -185,7 +185,7 @@ static void vba56_test_middle(int fd)
185 185
         if (vba_readn(fd, &test_middle, 20) != 20) {
186 186
                 return;
187 187
         }
188
-	
188
+
189 189
 	if (memcmp(test_middle, middle_str, 20) != 0) {
190 190
 	        lseek(fd, -20, SEEK_CUR);
191 191
 	}
... ...
@@ -205,7 +205,7 @@ static void vba56_test_end(int fd)
205 205
         if (vba_readn(fd, &test_end, 20) != 20) {
206 206
                 return;
207 207
         }
208
-                                                                                                                                    
208
+
209 209
         if (memcmp(test_end, end_str, 20) != 0) {
210 210
                 lseek(fd, -20, SEEK_CUR);
211 211
         }
... ...
@@ -238,7 +238,6 @@ vba_project_t *vba56_dir_read(const char *dir)
238 238
 
239 239
 	unsigned char fixed_octet[8] = { 0x06, 0x02, 0x01, 0x00, 0x08, 0x02, 0x00, 0x00 };
240 240
 
241
-
242 241
 	cli_dbgmsg("in vba56_dir_read()\n");
243 242
 
244 243
 	fullname = (char *) cli_malloc(strlen(dir) + 15);