Browse code

Bug 402

git-svn: trunk@2932

Nigel Horne authored on 2007/03/12 04:49:37
Showing 3 changed files
... ...
@@ -1,3 +1,8 @@
1
+Sun Mar 11 17:53:54 GMT 2007 (njh)
2
+----------------------------------
3
+  * libclamav/mbox.c:	Bug 402
4
+  * libclamav/message.c:	Mime_map is now constant
5
+
1 6
 Sun Mar 11 11:21:00 EET 2007 (edwin)
2 7
 ----------------------------------
3 8
   * libclamav/hashtab.[ch],phish_*,regex_list.[ch]: #include cleanup, Code
... ...
@@ -138,6 +138,8 @@ typedef	enum {
138 138
 				 * Trojan.WinREG.Zapchast which are often
139 139
 				 * dispatched by emails which point to it. If
140 140
 				 * not defined, don't check any URLs
141
+				 * It is also used to indicate the number of
142
+				 * 301/302 redirects we wish to follow
141 143
 				 */
142 144
 
143 145
 #ifdef	FOLLOWURLS
... ...
@@ -249,6 +251,7 @@ struct arg {
249 249
 	char *url;
250 250
 	const char *dir;
251 251
 	char *filename;
252
+	int	depth;
252 253
 };
253 254
 #ifdef	CL_THREAD_SAFE
254 255
 static	void	*getURL(void *a);
... ...
@@ -3997,11 +4000,13 @@ do_checkURLs(const char *dir, tag_arguments_t *hrefs)
3997 3997
 			args[n].dir = dir;
3998 3998
 			args[n].url = cli_strdup(url);
3999 3999
 			args[n].filename = cli_strdup(name);
4000
+			args[n].depth = 0;
4000 4001
 			pthread_create(&tid[n], NULL, getURL, &args[n]);
4001 4002
 #else
4002 4003
 			arg.url = cli_strdup(url);
4003 4004
 			arg.dir = dir;
4004 4005
 			arg.filename = name;
4006
+			arg.depth = 0;
4005 4007
 			getURL(&arg);
4006 4008
 			free(arg.url);
4007 4009
 #endif
... ...
@@ -4337,9 +4342,15 @@ getURL(struct arg *arg)
4337 4337
 					if(location) {
4338 4338
 						char *end;
4339 4339
 
4340
+						unlink(fout);
4341
+						if(arg->depth >= FOLLOWURLS) {
4342
+							cli_warnmsg("URL %s will not be followed to %s (FOLLOWURLS limit %d was reached)\n",
4343
+								arg->url, location, FOLLOWURLS);
4344
+							break;
4345
+						}
4346
+
4340 4347
 						fclose(fp);
4341 4348
 						closesocket(sd);
4342
-						unlink(fout);
4343 4349
 
4344 4350
 						location += 11;
4345 4351
 						free(arg->url);
... ...
@@ -4348,6 +4359,7 @@ getURL(struct arg *arg)
4348 4348
 							end++;
4349 4349
 						*end = '\0';
4350 4350
 						arg->url = cli_strdup(location);
4351
+						arg->depth++;
4351 4352
 						cli_dbgmsg("Redirecting to %s\n", arg->url);
4352 4353
 						return getURL(arg);
4353 4354
 					}
... ...
@@ -112,7 +112,7 @@ static	const	struct	encoding_map {
112 112
 	{	NULL,			NOENCODING	}
113 113
 };
114 114
 
115
-static	struct	mime_map {
115
+static	const	struct	mime_map {
116 116
 	const	char	*string;
117 117
 	mime_type	type;
118 118
 } mime_map[] = {