Browse code

* libclamav/ole2_extract.c: Fix Solaris endian issue. (bb#89) * libclamav/unrar/unrar.c: Fix FD leak in error path (bb#133, thanks acab)

git-svn: trunk@2504

Trog authored on 2006/11/14 22:52:39
Showing 3 changed files
... ...
@@ -1,3 +1,8 @@
1
+Tue Nov 14 13:49:58 GMT 2006 (trog)
2
+-----------------------------------
3
+  * libclamav/ole2_extract.c: Fix Solaris endian issue. (bb#89)
4
+  * libclamav/unrar/unrar.c: Fix FD leak in error path (bb#133, thanks acab)
5
+
1 6
 Sat Nov 11 20:09:07 GMT 2006 (njh)
2 7
 ----------------------------------
3 8
   * clamav-milter:	SESSIONS mode: force --external, bug 123
... ...
@@ -100,12 +100,12 @@ typedef struct ole2_header_tag
100 100
 typedef struct property_tag
101 101
 {
102 102
 	unsigned char name[64] __attribute__ ((packed));		/* in unicode */
103
-	int16_t name_size __attribute__ ((packed));
103
+	uint16_t name_size __attribute__ ((packed));
104 104
 	unsigned char type __attribute__ ((packed));			/* 1=dir 2=file 5=root */
105 105
 	unsigned char color __attribute__ ((packed));			/* black or red */
106
-	int32_t prev __attribute__ ((packed));
107
-	int32_t next __attribute__ ((packed));
108
-	int32_t child __attribute__ ((packed));
106
+	uint32_t prev __attribute__ ((packed));
107
+	uint32_t next __attribute__ ((packed));
108
+	uint32_t child __attribute__ ((packed));
109 109
 
110 110
 	unsigned char clsid[16] __attribute__ ((packed));
111 111
 	uint32_t user_flags __attribute__ ((packed));
... ...
@@ -114,8 +114,8 @@ typedef struct property_tag
114 114
 	uint32_t create_highdate __attribute__ ((packed));
115 115
 	uint32_t mod_lowdate __attribute__ ((packed));
116 116
 	uint32_t mod_highdate __attribute__ ((packed));
117
-	int32_t start_block __attribute__ ((packed));
118
-	int32_t size __attribute__ ((packed));
117
+	uint32_t start_block __attribute__ ((packed));
118
+	uint32_t size __attribute__ ((packed));
119 119
 	unsigned char reserved[4] __attribute__ ((packed));
120 120
 } property_t;
121 121
 
... ...
@@ -202,7 +202,7 @@ static void print_ole2_property(property_t *property)
202 202
 	default:
203 203
 		cli_dbgmsg(" u ");
204 204
 	}
205
-	cli_dbgmsg(" %d %x\n", property->size, property->user_flags);
205
+	cli_dbgmsg(" 0x%.8x 0x%.8x\n", property->size, property->user_flags);
206 206
 }
207 207
 
208 208
 static void print_ole2_header(ole2_header_t *hdr)
... ...
@@ -447,8 +447,9 @@ static void ole2_walk_property_tree(int fd, ole2_header_t *hdr, const char *dir,
447 447
 	property_t prop_block[4];
448 448
 	int32_t index, current_block, i;
449 449
 	unsigned char *dirname;
450
+
450 451
 	current_block = hdr->prop_start;
451
-	
452
+
452 453
 	if ((prop_index < 0) || (rec_level > 100) || (*file_count > 100000)) {
453 454
 		return;
454 455
 	}
... ...
@@ -602,7 +603,6 @@ static int handler_writefile(int fd, ole2_header_t *hdr, property_t *prop, const
602 602
                 }
603 603
 	}
604 604
 
605
-
606 605
 	newname = (char *) cli_malloc(strlen(name) + strlen(dir) + 2);
607 606
 	if (!newname) {
608 607
 		free(name);
... ...
@@ -1584,6 +1584,7 @@ rar_metadata_t *cli_unrar(int fd, const char *dirname, const struct cl_limits *l
1584 1584
 				} else {
1585 1585
 					if ((file_count == 1) && (file_header->flags & LHD_SOLID)) {
1586 1586
 						cli_warnmsg("RAR: First file can't be SOLID.\n");
1587
+						close(ofd);
1587 1588
 						break;
1588 1589
 					} else {
1589 1590
 						retval = rar_unpack(fd, file_header->unpack_ver,
... ...
@@ -1601,6 +1602,7 @@ rar_metadata_t *cli_unrar(int fd, const char *dirname, const struct cl_limits *l
1601 1601
 					cli_dbgmsg("Corrupt file detected\n");
1602 1602
 					if (file_header->flags & LHD_SOLID) {
1603 1603
 						cli_dbgmsg("SOLID archive, can't continue\n");
1604
+						close(ofd);
1604 1605
 						break;
1605 1606
 					}
1606 1607
 				}