Browse code

Fix crash on 64-bit Solaris Intel (bb #2314).

memcmp does 8-byte reads if length > 8, which might cross a page-boundary and
crash. Not strictly a memcmp bug, since manpage doesn't say that memcmp must stop at
first difference. Linux doesn't crash because it only does 4/8-byte reads on 4/8-byte aligned
addresses, hence it can never cross a page boundary.

Fix this by making sure that what we request from memcmp is entirely readable.

Török Edvin authored on 2010/10/05 23:01:26
Showing 2 changed files
... ...
@@ -1,3 +1,7 @@
1
+Tue Oct  5 17:03:43 EEST 2010 (edwin)
2
+-------------------------------------
3
+ * libclamav/pdf.c: Fix crash on 64-bit Solaris Intel (bb #2314).
4
+
1 5
 Tue Sep 28 16:25:03 EEST 2010 (edwin)
2 6
 -------------------------------------
3 7
  * libclamav/c++: allow building with external LLVM 2.8rc2.
... ...
@@ -1044,6 +1044,7 @@ int cli_pdf(const char *dir, cli_ctx *ctx, off_t offset)
1044 1044
     } else {
1045 1045
 	const char *t;
1046 1046
 	size = q - eofmap + map_off;
1047
+	q -= 9;
1047 1048
 	for (;q > eofmap;q--) {
1048 1049
 	    if (memcmp(q, "startxref", 9) == 0)
1049 1050
 		break;