git-svn: trunk@4795
Tomasz Kojm authored on 2009/02/17 01:29:44... | ... |
@@ -1,3 +1,7 @@ |
1 |
+Mon Feb 16 17:59:57 CET 2009 (tk) |
|
2 |
+--------------------------------- |
|
3 |
+ * libclamav, sigtool: fix handling of long signatures (bb#1395) |
|
4 |
+ |
|
1 | 5 |
Mon Feb 16 13:16:53 CET 2009 (tk) |
2 | 6 |
--------------------------------- |
3 | 7 |
* libclamav/clamd: fix double-slash when scanning the root dir (bb#1394) |
... | ... |
@@ -55,6 +55,7 @@ |
55 | 55 |
#include "filetypes_int.h" |
56 | 56 |
#include "readdb.h" |
57 | 57 |
#include "cltypes.h" |
58 |
+#include "default.h" |
|
58 | 59 |
|
59 | 60 |
#include "phishcheck.h" |
60 | 61 |
#include "phish_whitelist.h" |
... | ... |
@@ -796,7 +797,7 @@ static int lsigattribs(char *attribs, struct cli_lsig_tdb *tdb) |
796 | 796 |
static int cli_loadldb(FILE *fs, struct cl_engine *engine, unsigned int *signo, unsigned int options, struct cli_dbio *dbio, const char *dbname) |
797 | 797 |
{ |
798 | 798 |
char *tokens[LDB_TOKENS]; |
799 |
- char buffer[32768], *pt; |
|
799 |
+ char buffer[CLI_DEFAULT_LSIG_BUFSIZE + 1], *pt; |
|
800 | 800 |
const char *sig, *virname, *offset, *logic; |
801 | 801 |
struct cli_matcher *root; |
802 | 802 |
unsigned int line = 0, sigs = 0; |
... | ... |
@@ -810,7 +811,7 @@ static int cli_loadldb(FILE *fs, struct cl_engine *engine, unsigned int *signo, |
810 | 810 |
if((ret = cli_initroots(engine, options))) |
811 | 811 |
return ret; |
812 | 812 |
|
813 |
- while(cli_dbgets(buffer, FILEBUFF, fs, dbio)) { |
|
813 |
+ while(cli_dbgets(buffer, sizeof(buffer), fs, dbio)) { |
|
814 | 814 |
line++; |
815 | 815 |
sigs++; |
816 | 816 |
cli_chomp(buffer); |
... | ... |
@@ -40,6 +40,7 @@ |
40 | 40 |
#include "libclamav/str.h" |
41 | 41 |
#include "libclamav/others.h" |
42 | 42 |
#include "libclamav/cvd.h" |
43 |
+#include "libclamav/default.h" |
|
43 | 44 |
|
44 | 45 |
#include "zlib.h" |
45 | 46 |
|
... | ... |
@@ -353,7 +354,7 @@ static int cdiff_cmd_close(const char *cmdstr, struct cdiff_ctx *ctx) |
353 | 353 |
{ |
354 | 354 |
struct cdiff_node *add, *del, *xchg; |
355 | 355 |
unsigned int lines = 0; |
356 |
- char *tmp, line[1024]; |
|
356 |
+ char *tmp, line[CLI_DEFAULT_LSIG_BUFSIZE + 32]; |
|
357 | 357 |
FILE *fh, *tmpfh; |
358 | 358 |
|
359 | 359 |
|
... | ... |
@@ -489,7 +490,7 @@ static int cdiff_cmd_close(const char *cmdstr, struct cdiff_ctx *ctx) |
489 | 489 |
static int cdiff_cmd_move(const char *cmdstr, struct cdiff_ctx *ctx) |
490 | 490 |
{ |
491 | 491 |
unsigned int lines = 0, start_line, end_line; |
492 |
- char *arg, *srcdb, *dstdb, *tmpdb, line[1024], *start_str, *end_str; |
|
492 |
+ char *arg, *srcdb, *dstdb, *tmpdb, line[CLI_DEFAULT_LSIG_BUFSIZE + 32], *start_str, *end_str; |
|
493 | 493 |
FILE *src, *dst, *tmp; |
494 | 494 |
|
495 | 495 |
|
... | ... |
@@ -867,7 +868,7 @@ int cdiff_apply(int fd, unsigned short mode) |
867 | 867 |
struct cdiff_ctx ctx; |
868 | 868 |
FILE *fh; |
869 | 869 |
gzFile *gzh; |
870 |
- char line[1024], buff[FILEBUFF], *dsig = NULL; |
|
870 |
+ char line[CLI_DEFAULT_LSIG_BUFSIZE + 32], buff[FILEBUFF], *dsig = NULL; |
|
871 | 871 |
unsigned int lines = 0, cmds = 0; |
872 | 872 |
unsigned int difflen, diffremain; |
873 | 873 |
int end, i, n; |
... | ... |
@@ -60,9 +60,15 @@ |
60 | 60 |
#include "libclamav/str.h" |
61 | 61 |
#include "libclamav/ole2_extract.h" |
62 | 62 |
#include "libclamav/htmlnorm.h" |
63 |
+#include "libclamav/default.h" |
|
63 | 64 |
|
64 | 65 |
#define MAX_DEL_LOOKAHEAD 200 |
65 | 66 |
|
67 |
+/* |
|
68 |
+ * Force backward compatibility with the cdiff interpreter of clamav < 0.95 |
|
69 |
+ */ |
|
70 |
+#define COMPATIBILITY_LIMIT 896 |
|
71 |
+ |
|
66 | 72 |
static const struct dblist_s { |
67 | 73 |
const char *name; |
68 | 74 |
unsigned int count; |
... | ... |
@@ -1316,7 +1322,7 @@ static int rundiff(const struct optstruct *opts) |
1316 | 1316 |
static int compare(const char *oldpath, const char *newpath, FILE *diff) |
1317 | 1317 |
{ |
1318 | 1318 |
FILE *old, *new; |
1319 |
- char obuff[1024], nbuff[1024], tbuff[1024], *pt, *omd5, *nmd5; |
|
1319 |
+ char obuff[CLI_DEFAULT_LSIG_BUFSIZE + 1], nbuff[CLI_DEFAULT_LSIG_BUFSIZE + 1], tbuff[CLI_DEFAULT_LSIG_BUFSIZE + 1], *pt, *omd5, *nmd5; |
|
1320 | 1320 |
unsigned int oline = 0, tline, found, i; |
1321 | 1321 |
long opos; |
1322 | 1322 |
|
... | ... |
@@ -1347,7 +1353,14 @@ static int compare(const char *oldpath, const char *newpath, FILE *diff) |
1347 | 1347 |
|
1348 | 1348 |
while(fgets(nbuff, sizeof(nbuff), new)) { |
1349 | 1349 |
cli_chomp(nbuff); |
1350 |
- |
|
1350 |
+#ifdef COMPATIBILITY_LIMIT |
|
1351 |
+ if(strlen(nbuff) > COMPATIBILITY_LIMIT) { |
|
1352 |
+ mprintf("!compare: COMPATIBILITY_LIMIT: Line too long\n"); |
|
1353 |
+ if(old) |
|
1354 |
+ fclose(old); |
|
1355 |
+ return -1; |
|
1356 |
+ } |
|
1357 |
+#endif |
|
1351 | 1358 |
if(!old) { |
1352 | 1359 |
fprintf(diff, "ADD %s\n", nbuff); |
1353 | 1360 |
} else { |