Browse code

fix segfault in ole2

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

Tomasz Kojm authored on 2004/06/12 22:35:10
Showing 2 changed files
... ...
@@ -1,3 +1,8 @@
1
+Sat Jun 12 15:29:37 CEST 2004 (tk)
2
+----------------------------------
3
+  * libclamav: ole2_extract: fix segfault when mmap() fails (problem reported
4
+	       by Mehmet Ekiz <ekizm*tbmm.gov.tr>)
5
+
1 6
 Sat Jun 12 02:51:42 CEST 2004 (tk)
2 7
 ----------------------------------
3 8
   * contrib/trashscan: removed due to security reasons:
... ...
@@ -714,9 +714,10 @@ int cli_ole2_extract(int fd, const char *dirname)
714 714
 		hdr.m_area = (unsigned char *) mmap(NULL, hdr.m_length, PROT_READ, MAP_PRIVATE, fd, 0);
715 715
 		if (hdr.m_area == MAP_FAILED) {
716 716
 			hdr.m_area = NULL;
717
+		} else {
718
+			cli_dbgmsg("mmap'ed file\n");
719
+			memcpy(&hdr, hdr.m_area, hdr_size);
717 720
 		}
718
-		cli_dbgmsg("mmap'ed file\n");
719
-		memcpy(&hdr, hdr.m_area, hdr_size);
720 721
 	}
721 722
 #endif
722 723