Browse code

improve handling of corrupted/handcrafed headers (bb#511, patch from Trog)

git-svn: trunk@3082

Tomasz Kojm authored on 2007/05/30 05:23:30
Showing 2 changed files
... ...
@@ -1,3 +1,8 @@
1
+Tue May 29 21:47:23 CEST 2007 (tk)
2
+----------------------------------
3
+  * libclamav/unrar/unrar.c: improve handling of corrupted/handcrafed headers
4
+			     (bb#511, patch from Trog)
5
+
1 6
 Tue May 29 21:28:40 CEST 2007 (tk)
2 7
 ----------------------------------
3 8
   * libclamav/unsp.c: fix end of buffer calculation (bb#464, patch from aCaB)
... ...
@@ -1639,15 +1639,12 @@ int cli_unrar_extract_next(rar_state_t* state,const char* dirname)
1639 1639
 						((state->main_hdr->flags&MHD_SOLID)!=0), state->unpack_data);
1640 1640
 			} else {
1641 1641
 				if ((state->file_count == 1) && (state->file_header->flags & LHD_SOLID)) {
1642
-					cli_warnmsg("RAR: First file can't be SOLID.\n");
1643
-					
1644
-					free(state->file_header->filename);
1645
-					free(state->file_header);
1646
-					return CL_ERAR;
1647
-				} else {
1648
-					retval = rar_unpack(state->fd, state->file_header->unpack_ver,
1649
-							state->file_header->flags & LHD_SOLID,	state->unpack_data);
1642
+					cli_warnmsg("RAR: Bad header. First file can't be SOLID.\n");
1643
+					cli_warnmsg("RAR: Clearing flag and continuing.\n");
1644
+					state->file_header->flags -= LHD_SOLID;
1650 1645
 				}
1646
+				retval = rar_unpack(state->fd, state->file_header->unpack_ver,
1647
+							state->file_header->flags & LHD_SOLID,	state->unpack_data);
1651 1648
 			}
1652 1649
 			cli_dbgmsg("Expected File CRC: 0x%x\n", state->file_header->file_crc);
1653 1650
 			cli_dbgmsg("Computed File CRC: 0x%x\n", state->unpack_data->unp_crc^0xffffffff);