Browse code

bugfixes

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

Tomasz Kojm authored on 2004/09/16 01:51:33
Showing 5 changed files
... ...
@@ -1,3 +1,9 @@
1
+Wed Sep 15 18:46:44 CEST 2004 (tk)
2
+----------------------------------
3
+  * libclamav/matcher.c: fix problem with uninitialised voffset structure
4
+			 (thanks to Nigel)
5
+  * libclamav/str.c: check if memory is correctly allocated (thanks to Trog)
6
+
1 7
 Wed Sep 15 13:27:24 BST 2004 (trog)
2 8
 -----------------------------------
3 9
   * libclamav/htmlnorm.c: Error path cleanup. Fix bug spotted by Nigel.
... ...
@@ -118,6 +118,8 @@ int cli_scandesc(int desc, const char **virname, long int *scanned, const struct
118 118
     if(root->md5_hlist)
119 119
 	MD5Init(&ctx);
120 120
 
121
+    memset(&voffset, 0, sizeof(struct cli_voffset));
122
+
121 123
     buff = buffer;
122 124
     buff += root->maxpatlen; /* pointer to read data block */
123 125
     endbl = buff + SCANBUFF - root->maxpatlen; /* pointer to the last block
... ...
@@ -142,15 +144,15 @@ int cli_scandesc(int desc, const char **virname, long int *scanned, const struct
142 142
 
143 143
 	    if(voffset.target) {
144 144
 		if(voffset.target >= TARGET_TABLE_SIZE) {
145
-		    cli_errmsg("Bad target (%d) in signature for %s\n", voffset.target, virname);
145
+		    cli_errmsg("Bad target (%d) in signature for %s\n", voffset.target, *virname);
146 146
 		} else if(ftype && ftype != CL_TYPE_UNKNOWN_TEXT) {
147 147
 		    if(targettab[voffset.target] != ftype) {
148
-			cli_dbgmsg("Expected target type (%d) for %s != %d\n", voffset.target, virname, ftype);
148
+			cli_dbgmsg("Expected target type (%d) for %s != %d\n", voffset.target, *virname, ftype);
149 149
 			return CL_CLEAN;
150 150
 		    }
151 151
 		} else if(type) {
152 152
 		    if(targettab[voffset.target] != type) {
153
-			cli_dbgmsg("Expected target type (%d) for %s != %d\n", voffset.target, virname, type);
153
+			cli_dbgmsg("Expected target type (%d) for %s != %d\n", voffset.target, *virname, type);
154 154
 			return CL_CLEAN;
155 155
 		    }
156 156
 		}
... ...
@@ -665,7 +665,7 @@ int cl_loaddb(const char *filename, struct cl_node **root, unsigned int *signo)
665 665
 
666 666
 	ret = cli_cvdload(fd, root, signo, warn);
667 667
 
668
-    } else if(cli_strbcasestr(filename, ".hdb")) {
668
+    } else if(cli_strbcasestr(filename, ".hdb") || cli_strbcasestr(filename, ".hdb2")) {
669 669
 	ret = cli_loadhdb(fd, root, signo);
670 670
 
671 671
     } else if(cli_strbcasestr(filename, ".ndb")) {
... ...
@@ -704,11 +704,12 @@ int cl_loaddbdir(const char *dirname, struct cl_node **root, unsigned int *signo
704 704
 #endif
705 705
 	{
706 706
 	    if(strcmp(dent->d_name, ".") && strcmp(dent->d_name, "..") &&
707
-	    (cli_strbcasestr(dent->d_name, ".db")  ||
708
-	     cli_strbcasestr(dent->d_name, ".db2") ||
709
-	     cli_strbcasestr(dent->d_name, ".db3") ||
710
-	     cli_strbcasestr(dent->d_name, ".hdb") ||
711
-	     cli_strbcasestr(dent->d_name, ".ndb") ||
707
+	    (cli_strbcasestr(dent->d_name, ".db")   ||
708
+	     cli_strbcasestr(dent->d_name, ".db2")  ||
709
+	     cli_strbcasestr(dent->d_name, ".db3")  ||
710
+	     cli_strbcasestr(dent->d_name, ".hdb")  ||
711
+	     cli_strbcasestr(dent->d_name, ".hdb2") ||
712
+	     cli_strbcasestr(dent->d_name, ".ndb")  ||
712 713
 	     cli_strbcasestr(dent->d_name, ".cvd"))) {
713 714
 
714 715
 		dbfile = (char *) cli_calloc(strlen(dent->d_name) + strlen(dirname) + 2, sizeof(char));
... ...
@@ -772,6 +773,7 @@ int cl_statinidir(const char *dirname, struct cl_stat *dbstat)
772 772
 	    cli_strbcasestr(dent->d_name, ".db2")  || 
773 773
 	    cli_strbcasestr(dent->d_name, ".db3")  || 
774 774
 	    cli_strbcasestr(dent->d_name, ".hdb")  || 
775
+	    cli_strbcasestr(dent->d_name, ".hdb2") || 
775 776
 	    cli_strbcasestr(dent->d_name, ".ndb")  || 
776 777
 	    cli_strbcasestr(dent->d_name, ".cvd"))) {
777 778
 
... ...
@@ -820,6 +822,7 @@ int cl_statchkdir(const struct cl_stat *dbstat)
820 820
 	    cli_strbcasestr(dent->d_name, ".db2")  || 
821 821
 	    cli_strbcasestr(dent->d_name, ".db3")  || 
822 822
 	    cli_strbcasestr(dent->d_name, ".hdb")  || 
823
+	    cli_strbcasestr(dent->d_name, ".hdb2") || 
823 824
 	    cli_strbcasestr(dent->d_name, ".ndb")  || 
824 825
 	    cli_strbcasestr(dent->d_name, ".cvd"))) {
825 826
 
... ...
@@ -224,6 +224,8 @@ char *cli_strtok(const char *line, int fieldno, const char *delim)
224 224
 	return NULL;
225 225
     }
226 226
     buffer = malloc(j-i+1);
227
+    if(!buffer)
228
+	return NULL;
227 229
     strncpy(buffer, line+i, j-i);
228 230
     buffer[j-i] = '\0';
229 231
 
... ...
@@ -236,7 +236,7 @@ int build(struct optstruct *opt)
236 236
 	exit(1);
237 237
     }
238 238
 
239
-    if(stat("viruses.db", &foo) == -1 && stat("viruses.db2", &foo) == -1 && stat("malware.hdb", &foo) == -1) {
239
+    if(stat("viruses.db", &foo) == -1 && stat("viruses.db2", &foo) == -1 && stat("malware.hdb", &foo) == -1 && stat("malware.hdb2", &foo)) {
240 240
 	mprintf("Virus database not found in current working directory.\n");
241 241
 	exit(1);
242 242
     }
... ...
@@ -256,7 +256,7 @@ int build(struct optstruct *opt)
256 256
 	mprintf("WARNING: There are no signatures in the database(s).\n");
257 257
     } else {
258 258
 	mprintf("Signatures: %d\n", no);
259
-	realno = countlines("viruses.db") + countlines("viruses.db2") + countlines("malware.hdb");
259
+	realno = countlines("viruses.db") + countlines("viruses.db2") + countlines("malware.hdb") + countlines("malware.hdb2");
260 260
 
261 261
 	if(realno != no) {
262 262
 	    mprintf("!Signatures in database: %d. Loaded: %d.\n", realno, no);
... ...
@@ -274,7 +274,7 @@ int build(struct optstruct *opt)
274 274
 	    exit(1);
275 275
 	case 0:
276 276
 	    {
277
-		char *args[] = { "tar", "-cvf", NULL, "COPYING", "viruses.db", "viruses.db2", "Notes", "viruses.db3", "malware.hdb", NULL };
277
+		char *args[] = { "tar", "-cvf", NULL, "COPYING", "viruses.db", "viruses.db2", "Notes", "viruses.db3", "malware.hdb", "malware.hdb2", NULL };
278 278
 		args[2] = tarfile;
279 279
 		execv("/bin/tar", args);
280 280
 		mprintf("!Can't execute tar\n");
... ...
@@ -664,7 +664,7 @@ int listdb(const char *filename)
664 664
 	    mprintf("%s\n", start);
665 665
 	}
666 666
 
667
-    } else if(cli_strbcasestr(filename, ".hdb")) {
667
+    } else if(cli_strbcasestr(filename, ".hdb") || cli_strbcasestr(filename, ".hdb2")) {
668 668
 
669 669
 	while(fgets(buffer, FILEBUFF, fd)) {
670 670
 	    line++;
... ...
@@ -713,6 +713,7 @@ int listdir(const char *dirname)
713 713
 	    (cli_strbcasestr(dent->d_name, ".db")  ||
714 714
 	     cli_strbcasestr(dent->d_name, ".db2") ||
715 715
 	     cli_strbcasestr(dent->d_name, ".hdb") ||
716
+	     cli_strbcasestr(dent->d_name, ".hdb2") ||
716 717
 	     cli_strbcasestr(dent->d_name, ".cvd"))) {
717 718
 
718 719
 		dbfile = (char *) mcalloc(strlen(dent->d_name) + strlen(dirname) + 2, sizeof(char));