Browse code

Removed unneeded strdups

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

Nigel Horne authored on 2004/10/01 06:50:39
Showing 2 changed files
... ...
@@ -1,3 +1,9 @@
1
+Thu Sep 30 22:48:53 BST 2004 (njh)
2
+----------------------------------
3
+  * libclamav/mbox.c:	Remove unneeded strdup() calls
4
+			Fix some "filename too long" errors when MailFollowURLs
5
+				is set
6
+
1 7
 Thu Sep 30 20:19:46 BST 2004 (njh)
2 8
 ----------------------------------
3 9
   * clamav-milter:	Allow --from with no e-mail address
... ...
@@ -17,6 +17,9 @@
17 17
  *
18 18
  * Change History:
19 19
  * $Log: mbox.c,v $
20
+ * Revision 1.143  2004/09/30 21:47:35  nigelhorne
21
+ * Removed unneeded strdups
22
+ *
20 23
  * Revision 1.142  2004/09/28 18:40:12  nigelhorne
21 24
  * Use stack rather than heap where possible
22 25
  *
... ...
@@ -414,7 +417,7 @@
414 414
  * Compilable under SCO; removed duplicate code with message.c
415 415
  *
416 416
  */
417
-static	char	const	rcsid[] = "$Id: mbox.c,v 1.142 2004/09/28 18:40:12 nigelhorne Exp $";
417
+static	char	const	rcsid[] = "$Id: mbox.c,v 1.143 2004/09/30 21:47:35 nigelhorne Exp $";
418 418
 
419 419
 #if HAVE_CONFIG_H
420 420
 #include "clamav-config.h"
... ...
@@ -540,8 +543,8 @@ static	char	*rfc822comments(const char *in);
540 540
 static	void	checkURLs(message *m, const char *dir);
541 541
 #ifdef	WITH_CURL
542 542
 struct arg {
543
-	char *url;
544
-	char *dir;
543
+	const char *url;
544
+	const char *dir;
545 545
 	char *filename;
546 546
 };
547 547
 #ifdef	CL_THREAD_SAFE
... ...
@@ -2589,7 +2592,7 @@ checkURLs(message *m, const char *dir)
2589 2589
 			struct stat statb;
2590 2590
 			char cmd[512];
2591 2591
 #endif	/*WITH_CURL*/
2592
-			char name[NAME_MAX];
2592
+			char name[NAME_MAX + 1];
2593 2593
 
2594 2594
 			if(tableFind(t, url) == 1) {
2595 2595
 				cli_dbgmsg("URL %s already downloaded\n", url);
... ...
@@ -2608,8 +2611,8 @@ checkURLs(message *m, const char *dir)
2608 2608
 
2609 2609
 #ifdef	WITH_CURL
2610 2610
 #ifdef	CL_THREAD_SAFE
2611
-			args[n].url = strdup(url);
2612
-			args[n].dir = strdup(dir);
2611
+			args[n].dir = dir;
2612
+			args[n].url = url;
2613 2613
 			args[n].filename = strdup(name);
2614 2614
 			pthread_create(&tid[n], NULL, getURL, &args[n]);
2615 2615
 #else
... ...
@@ -2645,7 +2648,6 @@ checkURLs(message *m, const char *dir)
2645 2645
 			++n;
2646 2646
 		}
2647 2647
 	}
2648
-	html_tag_arg_free(&hrefs);
2649 2648
 	blobDestroy(b);
2650 2649
 	tableDestroy(t);
2651 2650
 
... ...
@@ -2654,11 +2656,10 @@ checkURLs(message *m, const char *dir)
2654 2654
 	cli_dbgmsg("checkURLs: waiting for %d thread(s) to finish\n", n);
2655 2655
 	while(--n >= 0) {
2656 2656
 		pthread_join(tid[n], NULL);
2657
-		free(args[n].url);
2658
-		free(args[n].dir);
2659 2657
 		free(args[n].filename);
2660 2658
 	}
2661 2659
 #endif
2660
+	html_tag_arg_free(&hrefs);
2662 2661
 }
2663 2662
 
2664 2663
 #ifdef	WITH_CURL
... ...
@@ -2715,7 +2716,7 @@ getURL(struct arg *arg)
2715 2715
 		return NULL;
2716 2716
 	}
2717 2717
 
2718
-	sprintf(fout, "%s/%s", dir, filename);
2718
+	snprintf(fout, NAME_MAX, "%s/%s", dir, filename);
2719 2719
 
2720 2720
 	fp = fopen(fout, "w");
2721 2721