git-svn: trunk@3568
Tomasz Kojm authored on 2008/02/01 00:51:13... | ... |
@@ -1,3 +1,7 @@ |
1 |
+Thu Jan 31 16:33:56 CET 2008 (tk) |
|
2 |
+--------------------------------- |
|
3 |
+ * libclamav/vba_extract.c: minor code tidy; drop broken sigtouint32() |
|
4 |
+ |
|
1 | 5 |
Thu Jan 31 12:59:18 CET 2008 (tk) |
2 | 6 |
--------------------------------- |
3 | 7 |
* libclamav, freshclam, sigtool: s/HAVE_GMP/HAVE_LIBGMP |
... | ... |
@@ -65,28 +65,28 @@ struct vba56_header { |
65 | 65 |
}; |
66 | 66 |
|
67 | 67 |
typedef struct { |
68 |
- unsigned char signature[4]; |
|
69 |
- const char *name; |
|
68 |
+ uint32_t sig; |
|
69 |
+ const char *ver; |
|
70 | 70 |
int big_endian; /* e.g. MAC Office */ |
71 | 71 |
} vba_version_t; |
72 | 72 |
|
73 | 73 |
/* from libgsf */ |
74 | 74 |
static const vba_version_t vba_versions[] = { |
75 |
- { { 0x5e, 0x00, 0x00, 0x01 }, "Office 97", FALSE }, |
|
76 |
- { { 0x5f, 0x00, 0x00, 0x01 }, "Office 97 SR1", FALSE }, |
|
77 |
- { { 0x65, 0x00, 0x00, 0x01 }, "Office 2000 alpha?", FALSE }, |
|
78 |
- { { 0x6b, 0x00, 0x00, 0x01 }, "Office 2000 beta?", FALSE }, |
|
79 |
- { { 0x6d, 0x00, 0x00, 0x01 }, "Office 2000", FALSE }, |
|
80 |
- { { 0x6f, 0x00, 0x00, 0x01 }, "Office 2000", FALSE }, |
|
81 |
- { { 0x70, 0x00, 0x00, 0x01 }, "Office XP beta 1/2", FALSE }, |
|
82 |
- { { 0x73, 0x00, 0x00, 0x01 }, "Office XP", FALSE }, |
|
83 |
- { { 0x76, 0x00, 0x00, 0x01 }, "Office 2003", FALSE }, |
|
84 |
- { { 0x79, 0x00, 0x00, 0x01 }, "Office 2003", FALSE }, |
|
85 |
- { { 0x60, 0x00, 0x00, 0x0e }, "MacOffice 98", TRUE }, |
|
86 |
- { { 0x62, 0x00, 0x00, 0x0e }, "MacOffice 2001", TRUE }, |
|
87 |
- { { 0x63, 0x00, 0x00, 0x0e }, "MacOffice X", TRUE }, |
|
88 |
- { { 0x64, 0x00, 0x00, 0x0e }, "MacOffice 2004", TRUE }, |
|
89 |
- { { 0x00, 0x00, 0x00, 0x00 }, NULL, FALSE }, |
|
75 |
+ { 0x0100005e, "97", FALSE }, |
|
76 |
+ { 0x0100005f, "97 SR1", FALSE }, |
|
77 |
+ { 0x01000065, "2000 alpha", FALSE }, |
|
78 |
+ { 0x0100006b, "2000 beta", FALSE }, |
|
79 |
+ { 0x0100006d, "2000", FALSE }, |
|
80 |
+ { 0x0100006f, "2000", FALSE }, |
|
81 |
+ { 0x01000070, "XP beta 1/2", FALSE }, |
|
82 |
+ { 0x01000073, "XP", FALSE }, |
|
83 |
+ { 0x01000073, "2003", FALSE }, |
|
84 |
+ { 0x01000079, "2003", FALSE }, |
|
85 |
+ { 0x0e000060, "98", TRUE }, |
|
86 |
+ { 0x0e000062, "2001", TRUE }, |
|
87 |
+ { 0x0e000063, "X", TRUE }, |
|
88 |
+ { 0x0e000064, "2004", TRUE }, |
|
89 |
+ { 0x00000000, NULL, FALSE }, |
|
90 | 90 |
}; |
91 | 91 |
|
92 | 92 |
static int skip_past_nul(int fd); |
... | ... |
@@ -94,7 +94,6 @@ static int read_uint16(int fd, uint16_t *u, int big_endian); |
94 | 94 |
static int read_uint32(int fd, uint32_t *u, int big_endian); |
95 | 95 |
static int seekandread(int fd, off_t offset, int whence, void *data, size_t len); |
96 | 96 |
static vba_project_t *create_vba_project(int record_count, const char *dir); |
97 |
-static uint32_t sigtouint32(const unsigned char *fourbytes); |
|
98 | 97 |
|
99 | 98 |
static uint16_t |
100 | 99 |
vba_endian_convert_16(uint16_t value, int big_endian) |
... | ... |
@@ -299,13 +298,12 @@ cli_vba_readdir(const char *dir) |
299 | 299 |
return NULL; |
300 | 300 |
} |
301 | 301 |
|
302 |
- sig = sigtouint32(v56h.version); |
|
303 |
- |
|
304 |
- for(v = vba_versions; v->name; v++) |
|
305 |
- if(sigtouint32(v->signature) == sig) |
|
302 |
+ sig = cli_readint32(v56h.version); |
|
303 |
+ for(v = vba_versions; v->sig; v++) |
|
304 |
+ if(v->sig == sig) |
|
306 | 305 |
break; |
307 | 306 |
|
308 |
- if(v->name == NULL) { |
|
307 |
+ if(!v->sig) { |
|
309 | 308 |
cli_warnmsg("Unknown VBA version signature %x %x %x %x\n", |
310 | 309 |
v56h.version[0], v56h.version[1], |
311 | 310 |
v56h.version[2], v56h.version[3]); |
... | ... |
@@ -324,7 +322,7 @@ cli_vba_readdir(const char *dir) |
324 | 324 |
return NULL; |
325 | 325 |
} |
326 | 326 |
} else { |
327 |
- cli_dbgmsg("VBA Project: %s\n", v->name); |
|
327 |
+ cli_dbgmsg("VBA Project: %s %s\n", v->big_endian ? "MacOffice" : "Office", v->ver); |
|
328 | 328 |
big_endian = v->big_endian; |
329 | 329 |
} |
330 | 330 |
|
... | ... |
@@ -528,18 +526,12 @@ cli_vba_inflate(int fd, off_t offset, int *size) |
528 | 528 |
(((srcpos % VBA_COMPRESSION_WINDOW) + len) < VBA_COMPRESSION_WINDOW) && |
529 | 529 |
(len <= VBA_COMPRESSION_WINDOW)) { |
530 | 530 |
srcpos %= VBA_COMPRESSION_WINDOW; |
531 |
- |
|
532 |
- cli_dbgmsg("memcpy(%u, %u, %d)\n", |
|
533 |
- winpos, srcpos, len); |
|
534 |
- |
|
535 | 531 |
memcpy(&buffer[winpos], &buffer[srcpos], |
536 | 532 |
len); |
537 | 533 |
pos += len; |
538 | 534 |
} else |
539 | 535 |
while(len-- > 0) { |
540 | 536 |
srcpos = (pos - distance - 1) % VBA_COMPRESSION_WINDOW; |
541 |
- cli_dbgmsg("Copying %u to %u\n", |
|
542 |
- srcpos, pos % VBA_COMPRESSION_WINDOW); |
|
543 | 537 |
buffer[pos++ % VBA_COMPRESSION_WINDOW] = buffer[srcpos]; |
544 | 538 |
} |
545 | 539 |
} else { |