git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@1314 77e5149b-7576-45b1-b177-96237e5ba77b
Nigel Horne authored on 2005/02/06 18:47:07... | ... |
@@ -1,3 +1,8 @@ |
1 |
+Sun Feb 6 09:45:53 GMT 2005 (njh) |
|
2 |
+---------------------------------- |
|
3 |
+ * libclamav/mbox.c: Speed up the (unimplemented) next generation of mbox |
|
4 |
+ code |
|
5 |
+ |
|
1 | 6 |
Sat Feb 5 16:48:46 CET 2005 (tk) |
2 | 7 |
--------------------------------- |
3 | 8 |
* libclamav: activate RIFF code (patch by Trog) |
... | ... |
@@ -17,6 +17,9 @@ |
17 | 17 |
* |
18 | 18 |
* Change History: |
19 | 19 |
* $Log: mbox.c,v $ |
20 |
+ * Revision 1.217 2005/02/06 09:45:53 nigelhorne |
|
21 |
+ * Speed up the (not implemented) next generation of mbox code |
|
22 |
+ * |
|
20 | 23 |
* Revision 1.216 2005/02/06 09:21:55 nigelhorne |
21 | 24 |
* Better check for boundaries with comments |
22 | 25 |
* |
... | ... |
@@ -636,7 +639,7 @@ |
636 | 636 |
* Compilable under SCO; removed duplicate code with message.c |
637 | 637 |
* |
638 | 638 |
*/ |
639 |
-static char const rcsid[] = "$Id: mbox.c,v 1.216 2005/02/06 09:21:55 nigelhorne Exp $"; |
|
639 |
+static char const rcsid[] = "$Id: mbox.c,v 1.217 2005/02/06 09:45:53 nigelhorne Exp $"; |
|
640 | 640 |
|
641 | 641 |
#if HAVE_CONFIG_H |
642 | 642 |
#include "clamav-config.h" |
... | ... |
@@ -953,6 +956,8 @@ cli_mbox(const char *dir, int desc, unsigned int options) |
953 | 953 |
message *m; |
954 | 954 |
fileblob *fb; |
955 | 955 |
int ret = 0; |
956 |
+ char *buf; |
|
957 |
+ int wasAlloced; |
|
956 | 958 |
|
957 | 959 |
if(fstat(desc, &statb) < 0) |
958 | 960 |
return CL_EOPEN; |
... | ... |
@@ -1005,9 +1010,16 @@ cli_mbox(const char *dir, int desc, unsigned int options) |
1005 | 1005 |
|
1006 | 1006 |
/* |
1007 | 1007 |
* Would be nice to have a case insensitive cli_memstr() |
1008 |
- * |
|
1009 |
- * This is v. slow especially on large files |
|
1010 | 1008 |
*/ |
1009 |
+ buf = cli_malloc(bodysize); |
|
1010 |
+ if(buf) { |
|
1011 |
+ wasAlloced = 1; |
|
1012 |
+ memcpy(buf, ptr, bodysize); |
|
1013 |
+ munmap(start, size); |
|
1014 |
+ ptr = start = buf; |
|
1015 |
+ } else |
|
1016 |
+ wasAlloced = 0; |
|
1017 |
+ |
|
1011 | 1018 |
if((p = (char *)cli_pmemstr(ptr, bodysize, "base64", 6)) != NULL) { |
1012 | 1019 |
cli_dbgmsg("Header base64\n"); |
1013 | 1020 |
decoder |= 1; |
... | ... |
@@ -1036,8 +1048,12 @@ cli_mbox(const char *dir, int desc, unsigned int options) |
1036 | 1036 |
} |
1037 | 1037 |
|
1038 | 1038 |
if(decoder == 0) { |
1039 |
- munmap(start, size); |
|
1039 |
+ if(wasAlloced) |
|
1040 |
+ free(start); |
|
1041 |
+ else |
|
1042 |
+ munmap(start, size); |
|
1040 | 1043 |
cli_dbgmsg("cli_mbox: unknown encoder\n"); |
1044 |
+ printf("cli_mbox: unknown encoder\n"); |
|
1041 | 1045 |
return cli_parse_mbox(dir, desc, options); |
1042 | 1046 |
} |
1043 | 1047 |
|
... | ... |
@@ -1202,8 +1218,14 @@ cli_mbox(const char *dir, int desc, unsigned int options) |
1202 | 1202 |
} |
1203 | 1203 |
} |
1204 | 1204 |
|
1205 |
- munmap(start, size); |
|
1205 |
+ if(wasAlloced) |
|
1206 |
+ free(start); |
|
1207 |
+ else |
|
1208 |
+ munmap(start, size); |
|
1206 | 1209 |
|
1210 |
+ /* |
|
1211 |
+ * FIXME: Need to run cl_scandir() here and return that value |
|
1212 |
+ */ |
|
1207 | 1213 |
if(ret == 0) |
1208 | 1214 |
return CL_CLEAN; /* a lie - but it gets things going */ |
1209 | 1215 |
|