Browse code

do not report I/O error on bad e_lfanew's

git-svn: trunk@671

Tomasz Kojm authored on 2004/07/16 07:46:11
Showing 2 changed files
... ...
@@ -1,3 +1,7 @@
1
+Fri Jul 16 00:38:46 CEST 2004 (tk)
2
+----------------------------------
3
+  * libclamav: pe: do not report I/O error on bad e_lfanew's
4
+
1 5
 Wed Jul 14 13:31:41 CEST 2004 (tk)
2 6
 ----------------------------------
3 7
   * libclamav: fix detection of mail files
... ...
@@ -262,11 +262,17 @@ int cli_scanpe(int desc, const char **virname, long int *scanned, const struct c
262 262
 	cli_dbgmsg("Not a PE file\n");
263 263
 	return CL_CLEAN;
264 264
     }
265
-    lseek(desc, e_lfanew, SEEK_SET);
265
+
266
+    if(lseek(desc, e_lfanew, SEEK_SET) < 0) {
267
+	/* probably not a PE file */
268
+	cli_dbgmsg("Can't lseek to e_lfanew\n");
269
+	return CL_CLEAN;
270
+    }
266 271
 
267 272
     if(read(desc, &file_hdr, sizeof(struct pe_image_file_hdr)) != sizeof(struct pe_image_file_hdr)) {
273
+	/* bad information in e_lfanew - probably not a PE file */
268 274
 	cli_dbgmsg("Can't read file header\n");
269
-	return CL_EIO;
275
+	return CL_CLEAN;
270 276
     }
271 277
 
272 278
     if(EC32(file_hdr.Magic) != IMAGE_NT_SIGNATURE) {