Browse code

Handle more cases of broken executables

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

Tomasz Kojm authored on 2004/08/26 09:22:11
Showing 2 changed files
... ...
@@ -1,3 +1,7 @@
1
+Thu Aug 26 02:19:47 CEST 2004 (tk)
2
+----------------------------------
3
+  * libclamav/pe.c: Handle more cases of broken executables
4
+
1 5
 Wed Aug 25 13:32:22 BST 2004 (njh)
2 6
 ----------------------------------
3 7
   * libclamav/line.c:	Small code optimisation
... ...
@@ -161,7 +161,7 @@ int cli_scanpe(int desc, const char **virname, long int *scanned, const struct c
161 161
 
162 162
     if(read(desc, &e_magic, sizeof(e_magic)) != sizeof(e_magic)) {
163 163
 	cli_dbgmsg("Can't read DOS signature\n");
164
-	return CL_EIO;
164
+	return CL_CLEAN;
165 165
     }
166 166
 
167 167
     if(EC16(e_magic) != IMAGE_DOS_SIGNATURE && EC16(e_magic) != IMAGE_DOS_SIGNATURE_OLD) {
... ...
@@ -173,7 +173,13 @@ int cli_scanpe(int desc, const char **virname, long int *scanned, const struct c
173 173
 
174 174
     if(read(desc, &e_lfanew, sizeof(e_lfanew)) != sizeof(e_lfanew)) {
175 175
 	cli_dbgmsg("Can't read new header address\n");
176
-	return CL_EIO;
176
+	/* truncated header? */
177
+	if(DETECT_BROKEN) {
178
+	    if(virname)
179
+		*virname = "Broken.Executable";
180
+	    return CL_VIRUS;
181
+	}
182
+	return CL_CLEAN;
177 183
     }
178 184
 
179 185
     e_lfanew = EC32(e_lfanew);