Browse code

Rehashed readdir_r patch

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

Nigel Horne authored on 2004/11/04 19:15:49
Showing 2 changed files
... ...
@@ -1,3 +1,7 @@
1
+Thu Nov  4 10:14:57 GMT 2004 (njh)
2
+----------------------------------
3
+  * libclamav/mbox.c:	Applied readdir_r patch from TK
4
+
1 5
 Thu Nov  4 08:24:21 GMT 2004 (njh)
2 6
 ----------------------------------
3 7
   * libclamav/clamav-milter:	Fix segfault on startup in LocalSocket mode in
... ...
@@ -17,6 +17,9 @@
17 17
  *
18 18
  * Change History:
19 19
  * $Log: mbox.c,v $
20
+ * Revision 1.164  2004/11/04 10:13:41  nigelhorne
21
+ * Rehashed readdir_r patch
22
+ *
20 23
  * Revision 1.163  2004/10/31 09:28:56  nigelhorne
21 24
  * Handle unbalanced quotes in multipart headers
22 25
  *
... ...
@@ -477,7 +480,7 @@
477 477
  * Compilable under SCO; removed duplicate code with message.c
478 478
  *
479 479
  */
480
-static	char	const	rcsid[] = "$Id: mbox.c,v 1.163 2004/10/31 09:28:56 nigelhorne Exp $";
480
+static	char	const	rcsid[] = "$Id: mbox.c,v 1.164 2004/11/04 10:13:41 nigelhorne Exp $";
481 481
 
482 482
 #if HAVE_CONFIG_H
483 483
 #include "clamav-config.h"
... ...
@@ -510,6 +513,10 @@ static	char	const	rcsid[] = "$Id: mbox.c,v 1.163 2004/10/31 09:28:56 nigelhorne
510 510
 #include <dirent.h>
511 511
 #include <limits.h>
512 512
 
513
+#if defined(HAVE_READDIR_R_3) || defined(HAVE_READDIR_R_2)
514
+#include <stddef.h>
515
+#endif
516
+
513 517
 #ifdef	CL_THREAD_SAFE
514 518
 #include <pthread.h>
515 519
 #endif
... ...
@@ -2836,30 +2843,18 @@ rfc1341(message *m, const char *dir)
2836 2836
 				char filename[NAME_MAX + 1];
2837 2837
 				const struct dirent *dent;
2838 2838
 #if defined(HAVE_READDIR_R_3) || defined(HAVE_READDIR_R_2)
2839
-#if	defined(C_SOLARIS) || defined(C_BEOS)
2840
-				char result[sizeof(struct dirent) + PATH_MAX + 1];
2841
-#else
2842
-				struct dirent result;
2843
-#endif
2839
+				union {
2840
+					struct dirent d;
2841
+					char b[offsetof(struct dirent, d_name) + NAME_MAX + 1];
2842
+				} result;
2844 2843
 #endif
2845 2844
 
2846 2845
 				snprintf(filename, sizeof(filename), "%s%d", id, n);
2847
-#ifdef HAVE_READDIR_R_3
2848
-
2849
-#if	defined(C_SOLARIS) || defined(C_BEOS)
2850
-				while((readdir_r(dd, (struct dirent *)result, &dent) == 0) && dent) {
2851
-#else
2852
-				while((readdir_r(dd, (struct dirent *)&result, &dent) == 0) && dent) {
2853
-#endif
2854 2846
 
2847
+#ifdef HAVE_READDIR_R_3
2848
+				while((readdir_r(dd, &result.d, &dent) == 0) && dent) {
2855 2849
 #elif defined(HAVE_READDIR_R_2)
2856
-
2857
-#if	defined(C_SOLARIS) || defined(C_BEOS)
2858
-				while((dent = (struct dirent *)readdir_r(dd, (struct dirent *)&result))) {
2859
-#else
2860
-				while((dent = (struct dirent *)readdir_r(dd, (struct dirent *)result))) {
2861
-#endif
2862
-
2850
+				while((dent = (struct dirent *)readdir_r(dd, &result.d))) {
2863 2851
 #else	/*!HAVE_READDIR_R*/
2864 2852
 				while((dent = readdir(dd))) {
2865 2853
 #endif
... ...
@@ -2975,7 +2970,7 @@ checkURLs(message *m, const char *dir)
2975 2975
 	n = 0;
2976 2976
 
2977 2977
 	for(i = 0; i < hrefs.count; i++) {
2978
-		const char *url = hrefs.value[i];
2978
+		const char *url = (const char *)hrefs.value[i];
2979 2979
 
2980 2980
 		if(strncasecmp("http://", url, 7) == 0) {
2981 2981
 			char *ptr;