git-svn: trunk@3482
Nigel Horne authored on 2008/01/05 19:57:19... | ... |
@@ -70,6 +70,25 @@ typedef struct { |
70 | 70 |
int big_endian; /* e.g. MAC Office */ |
71 | 71 |
} vba_version_t; |
72 | 72 |
|
73 |
+/* from libgsf */ |
|
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 }, |
|
90 |
+}; |
|
91 |
+ |
|
73 | 92 |
static int skip_past_nul(int fd); |
74 | 93 |
static int read_uint16(int fd, uint16_t *u, int big_endian); |
75 | 94 |
static int read_uint32(int fd, uint32_t *u, int big_endian); |
... | ... |
@@ -77,7 +96,8 @@ static int seekandread(int fd, off_t offset, int whence, void *data, size_t len) |
77 | 77 |
static vba_project_t *create_vba_project(int record_count, const char *dir); |
78 | 78 |
static uint32_t sigtouint32(const unsigned char *fourbytes); |
79 | 79 |
|
80 |
-static uint16_t vba_endian_convert_16(uint16_t value, int big_endian) |
|
80 |
+static uint16_t |
|
81 |
+vba_endian_convert_16(uint16_t value, int big_endian) |
|
81 | 82 |
{ |
82 | 83 |
if (big_endian) |
83 | 84 |
return (uint16_t)be16_to_host(value); |
... | ... |
@@ -86,7 +106,8 @@ static uint16_t vba_endian_convert_16(uint16_t value, int big_endian) |
86 | 86 |
} |
87 | 87 |
|
88 | 88 |
/* Seems to be a duplicate of riff_endian_convert_32() */ |
89 |
-static uint32_t vba_endian_convert_32(uint32_t value, int big_endian) |
|
89 |
+static uint32_t |
|
90 |
+vba_endian_convert_32(uint32_t value, int big_endian) |
|
90 | 91 |
{ |
91 | 92 |
if (big_endian) |
92 | 93 |
return be32_to_host(value); |
... | ... |
@@ -94,25 +115,6 @@ static uint32_t vba_endian_convert_32(uint32_t value, int big_endian) |
94 | 94 |
return le32_to_host(value); |
95 | 95 |
} |
96 | 96 |
|
97 |
-/* from libgsf */ |
|
98 |
-static const vba_version_t vba_versions[] = { |
|
99 |
- { { 0x5e, 0x00, 0x00, 0x01 }, "Office 97", FALSE }, |
|
100 |
- { { 0x5f, 0x00, 0x00, 0x01 }, "Office 97 SR1", FALSE }, |
|
101 |
- { { 0x65, 0x00, 0x00, 0x01 }, "Office 2000 alpha?", FALSE }, |
|
102 |
- { { 0x6b, 0x00, 0x00, 0x01 }, "Office 2000 beta?", FALSE }, |
|
103 |
- { { 0x6d, 0x00, 0x00, 0x01 }, "Office 2000", FALSE }, |
|
104 |
- { { 0x6f, 0x00, 0x00, 0x01 }, "Office 2000", FALSE }, |
|
105 |
- { { 0x70, 0x00, 0x00, 0x01 }, "Office XP beta 1/2", FALSE }, |
|
106 |
- { { 0x73, 0x00, 0x00, 0x01 }, "Office XP", FALSE }, |
|
107 |
- { { 0x76, 0x00, 0x00, 0x01 }, "Office 2003", FALSE }, |
|
108 |
- { { 0x79, 0x00, 0x00, 0x01 }, "Office 2003", FALSE }, |
|
109 |
- { { 0x60, 0x00, 0x00, 0x0e }, "MacOffice 98", TRUE }, |
|
110 |
- { { 0x62, 0x00, 0x00, 0x0e }, "MacOffice 2001", TRUE }, |
|
111 |
- { { 0x63, 0x00, 0x00, 0x0e }, "MacOffice X", TRUE }, |
|
112 |
- { { 0x64, 0x00, 0x00, 0x0e }, "MacOffice 2004", TRUE }, |
|
113 |
- { { 0x00, 0x00, 0x00, 0x00 }, NULL, FALSE }, |
|
114 |
-}; |
|
115 |
- |
|
116 | 97 |
static char * |
117 | 98 |
get_unicode_name(const char *name, int size, int big_endian) |
118 | 99 |
{ |
... | ... |
@@ -332,12 +334,12 @@ cli_vba_readdir(const char *dir) |
332 | 332 |
} |
333 | 333 |
|
334 | 334 |
/* junk some more stuff */ |
335 |
- do { |
|
335 |
+ do |
|
336 | 336 |
if (cli_readn(fd, &ffff, 2) != 2) { |
337 | 337 |
close(fd); |
338 | 338 |
return NULL; |
339 | 339 |
} |
340 |
- } while(ffff != 0xFFFF); |
|
340 |
+ while(ffff != 0xFFFF); |
|
341 | 341 |
|
342 | 342 |
/* check for alignment error */ |
343 | 343 |
if(!seekandread(fd, -3, SEEK_CUR, &ffff, sizeof(uint16_t))) { |
... | ... |
@@ -391,6 +393,7 @@ cli_vba_readdir(const char *dir) |
391 | 391 |
buflen = 0; |
392 | 392 |
for(i = 0; i < record_count; i++) { |
393 | 393 |
uint16_t length; |
394 |
+ char *ptr; |
|
394 | 395 |
|
395 | 396 |
if(!read_uint16(fd, &length, big_endian)) |
396 | 397 |
break; |
... | ... |
@@ -410,30 +413,30 @@ cli_vba_readdir(const char *dir) |
410 | 410 |
cli_dbgmsg("read name failed\n"); |
411 | 411 |
break; |
412 | 412 |
} |
413 |
- vba_project->name[i] = get_unicode_name((const char *)buf, length, big_endian); |
|
414 |
- if (!vba_project->name[i]) { |
|
413 |
+ ptr = get_unicode_name((const char *)buf, length, big_endian); |
|
414 |
+ if(ptr == NULL) { |
|
415 | 415 |
offset = lseek(fd, 0, SEEK_CUR); |
416 |
- vba_project->name[i] = (char *) cli_malloc(18); |
|
417 |
- if(vba_project->name[i] == NULL) |
|
416 |
+ ptr = (char *)cli_malloc(18); |
|
417 |
+ if(ptr == NULL) |
|
418 | 418 |
break; |
419 |
- sprintf(vba_project->name[i], "clamav-%.10d", (int)offset); |
|
419 |
+ sprintf(ptr, "clamav-%.10d", (int)offset); |
|
420 | 420 |
} |
421 |
- cli_dbgmsg("project name: %s\n", vba_project->name[i]); |
|
421 |
+ cli_dbgmsg("project name: %s\n", ptr); |
|
422 | 422 |
|
423 | 423 |
if(!read_uint16(fd, &length, big_endian)) { |
424 |
- free(vba_project->name[i]); |
|
424 |
+ free(ptr); |
|
425 | 425 |
break; |
426 | 426 |
} |
427 | 427 |
lseek(fd, length, SEEK_CUR); |
428 | 428 |
|
429 | 429 |
if(!read_uint16(fd, &ffff, big_endian)) { |
430 |
- free(vba_project->name[i]); |
|
430 |
+ free(ptr); |
|
431 | 431 |
break; |
432 | 432 |
} |
433 | 433 |
if (ffff == 0xFFFF) { |
434 | 434 |
lseek(fd, 2, SEEK_CUR); |
435 | 435 |
if(!read_uint16(fd, &ffff, big_endian)) { |
436 |
- free(vba_project->name[i]); |
|
436 |
+ free(ptr); |
|
437 | 437 |
break; |
438 | 438 |
} |
439 | 439 |
lseek(fd, ffff + 8, SEEK_CUR); |
... | ... |
@@ -441,16 +444,17 @@ cli_vba_readdir(const char *dir) |
441 | 441 |
lseek(fd, ffff + 10, SEEK_CUR); |
442 | 442 |
|
443 | 443 |
if(!read_uint16(fd, &byte_count, big_endian)) { |
444 |
- free(vba_project->name[i]); |
|
444 |
+ free(ptr); |
|
445 | 445 |
break; |
446 | 446 |
} |
447 | 447 |
lseek(fd, (8 * byte_count) + 5, SEEK_CUR); |
448 | 448 |
if(!read_uint32(fd, &offset, big_endian)) { |
449 |
- free(vba_project->name[i]); |
|
449 |
+ free(ptr); |
|
450 | 450 |
break; |
451 | 451 |
} |
452 |
- vba_project->offset[i] = offset; |
|
453 | 452 |
cli_dbgmsg("offset: %u\n", (unsigned int)offset); |
453 |
+ vba_project->offset[i] = offset; |
|
454 |
+ vba_project->name[i] = ptr; |
|
454 | 455 |
lseek(fd, 2, SEEK_CUR); |
455 | 456 |
} |
456 | 457 |
|