git-svn: trunk@2517
Tomasz Kojm authored on 2006/11/24 09:17:30... | ... |
@@ -1,3 +1,8 @@ |
1 |
+Fri Nov 24 01:15:28 CET 2006 (tk) |
|
2 |
+--------------------------------- |
|
3 |
+ * libclamav/matcher.c: minor code cleanup (bb#148), thanks to Christophe |
|
4 |
+ JAILLET <christophe.jaillet*wanadoo.fr> |
|
5 |
+ |
|
1 | 6 |
Thu Nov 23 09:47:13 GMT 2006 (njh) |
2 | 7 |
---------------------------------- |
3 | 8 |
* libclamav/jscript.c: Improved the handling of runaway JS programs |
... | ... |
@@ -54,7 +54,7 @@ extern short cli_debug_flag; |
54 | 54 |
|
55 | 55 |
int cli_scanbuff(const unsigned char *buffer, unsigned int length, const char **virname, const struct cl_engine *engine, unsigned short ftype) |
56 | 56 |
{ |
57 |
- int ret = CL_CLEAN, i, tid = 0; |
|
57 |
+ int ret = CL_CLEAN, i; |
|
58 | 58 |
struct cli_ac_data mdata; |
59 | 59 |
struct cli_matcher *groot, *troot = NULL; |
60 | 60 |
#ifdef HAVE_NCORE |
... | ... |
@@ -197,14 +197,12 @@ int cli_scanbuff(const unsigned char *buffer, unsigned int length, const char ** |
197 | 197 |
groot = engine->root[0]; /* generic signatures */ |
198 | 198 |
|
199 | 199 |
if(ftype) { |
200 |
- for(i = 0; i < CL_TARGET_TABLE_SIZE; i++) { |
|
200 |
+ for(i = 1; i < CL_TARGET_TABLE_SIZE; i++) { |
|
201 | 201 |
if(targettab[i] == ftype) { |
202 |
- tid = i; |
|
202 |
+ troot = engine->root[i]; |
|
203 | 203 |
break; |
204 | 204 |
} |
205 | 205 |
} |
206 |
- if(tid) |
|
207 |
- troot = engine->root[tid]; |
|
208 | 206 |
} |
209 | 207 |
|
210 | 208 |
if(troot) { |
... | ... |
@@ -407,7 +405,7 @@ int cli_validatesig(unsigned short ftype, const char *offstr, off_t fileoff, str |
407 | 407 |
int cli_scandesc(int desc, cli_ctx *ctx, unsigned short otfrec, unsigned short ftype, struct cli_matched_type **ftoffset) |
408 | 408 |
{ |
409 | 409 |
unsigned char *buffer, *buff, *endbl, *upt; |
410 |
- int ret = CL_CLEAN, type = CL_CLEAN, i, tid = 0, bytes; |
|
410 |
+ int ret = CL_CLEAN, type = CL_CLEAN, i, bytes; |
|
411 | 411 |
unsigned int buffersize, length, maxpatlen, shift = 0; |
412 | 412 |
unsigned long int offset = 0; |
413 | 413 |
struct cli_ac_data gdata, tdata; |
... | ... |
@@ -654,14 +652,12 @@ int cli_scandesc(int desc, cli_ctx *ctx, unsigned short otfrec, unsigned short f |
654 | 654 |
groot = ctx->engine->root[0]; /* generic signatures */ |
655 | 655 |
|
656 | 656 |
if(ftype) { |
657 |
- for(i = 0; i < CL_TARGET_TABLE_SIZE; i++) { |
|
657 |
+ for(i = 1; i < CL_TARGET_TABLE_SIZE; i++) { |
|
658 | 658 |
if(targettab[i] == ftype) { |
659 |
- tid = i; |
|
659 |
+ troot = ctx->engine->root[i]; |
|
660 | 660 |
break; |
661 | 661 |
} |
662 | 662 |
} |
663 |
- if(tid) |
|
664 |
- troot = ctx->engine->root[tid]; |
|
665 | 663 |
} |
666 | 664 |
|
667 | 665 |
if(troot) |
... | ... |
@@ -736,7 +732,7 @@ int cli_scandesc(int desc, cli_ctx *ctx, unsigned short otfrec, unsigned short f |
736 | 736 |
return CL_VIRUS; |
737 | 737 |
|
738 | 738 |
} else if(otfrec && ret >= CL_TYPENO) { |
739 |
- if(ret >= type) |
|
739 |
+ if(ret > type) |
|
740 | 740 |
type = ret; |
741 | 741 |
} |
742 | 742 |
|