git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@1028 77e5149b-7576-45b1-b177-96237e5ba77b
Tomasz Kojm authored on 2004/10/21 05:20:20... | ... |
@@ -92,6 +92,7 @@ Alejandro Dubrovsky <s328940*student.uq.edu.au> |
92 | 92 |
Magnus Ekdahl <magnus*debian.org> |
93 | 93 |
Jens Elkner <elkner*linofee.org> |
94 | 94 |
Jason Englander <jason*englanders.cc> |
95 |
+Andy Fiddaman <clam*fiddaman.net> |
|
95 | 96 |
Tony Finch <dot*dotat.at> |
96 | 97 |
David Ford <david+cert*blue-labs.org> |
97 | 98 |
Piotr Gackiewicz <gacek*intertele.pl> |
... | ... |
@@ -1,3 +1,9 @@ |
1 |
+Wed Oct 20 22:16:58 CEST 2004 (tk) |
|
2 |
+---------------------------------- |
|
3 |
+ * libclamav, clamd: fix possible stack corruption under Solaris (only when |
|
4 |
+ compiled with --enable-readdir_r). Thanks to Andy |
|
5 |
+ Fiddaman <clam*fiddaman.net>. |
|
6 |
+ |
|
1 | 7 |
Wed Oct 20 21:00:37 CEST 2004 (tk) |
2 | 8 |
---------------------------------- |
3 | 9 |
* clamdscan: fix error messages (problem reported by Jason Haar |
... | ... |
@@ -11,13 +17,13 @@ Wed Oct 20 11:37:40 BST 2004 (njh) |
11 | 11 |
---------------------------------- |
12 | 12 |
* libclamav/mbox.c: PARTIAL MODE ONLY: fixed possible stack corruption |
13 | 13 |
under Solaris, patch from Andy Fiddaman |
14 |
- <clam@fiddaman.net> |
|
14 |
+ <clam*fiddaman.net> |
|
15 | 15 |
|
16 | 16 |
Tue Oct 19 14:56:27 BST 2004 (njh) |
17 | 17 |
---------------------------------- |
18 | 18 |
* libclamav/message.c: Some base64 encoders encode extra NUL bytes |
19 | 19 |
at the end - ensure that they aren't added when |
20 |
- decoding, reported by James Lick <jlick@drivel.com> |
|
20 |
+ decoding, reported by James Lick <jlick*drivel.com> |
|
21 | 21 |
|
22 | 22 |
Tue Oct 19 02:53:46 CEST 2004 (tk) |
23 | 23 |
---------------------------------- |
... | ... |
@@ -36,6 +36,12 @@ |
36 | 36 |
#include <clamav.h> |
37 | 37 |
#include <pthread.h> |
38 | 38 |
|
39 |
+#if defined(HAVE_READDIR_R_3) || defined(HAVE_READDIR_R_2) |
|
40 |
+#ifdef C_SOLARIS |
|
41 |
+#include <limits.h> |
|
42 |
+#endif |
|
43 |
+#endif |
|
44 |
+ |
|
39 | 45 |
#include "cfgparser.h" |
40 | 46 |
#include "others.h" |
41 | 47 |
#include "scanner.h" |
... | ... |
@@ -74,8 +80,12 @@ int dirscan(const char *dirname, const char **virname, unsigned long int *scanne |
74 | 74 |
DIR *dd; |
75 | 75 |
struct dirent *dent; |
76 | 76 |
#if defined(HAVE_READDIR_R_3) || defined(HAVE_READDIR_R_2) |
77 |
+#ifdef C_SOLARIS |
|
78 |
+ char result[sizeof(struct dirent) + MAX_PATH + 1]; |
|
79 |
+#else |
|
77 | 80 |
struct dirent result; |
78 | 81 |
#endif |
82 |
+#endif |
|
79 | 83 |
struct stat statbuf; |
80 | 84 |
struct cfgstruct *cpt; |
81 | 85 |
char *fname; |
... | ... |
@@ -97,9 +107,9 @@ int dirscan(const char *dirname, const char **virname, unsigned long int *scanne |
97 | 97 |
|
98 | 98 |
if((dd = opendir(dirname)) != NULL) { |
99 | 99 |
#ifdef HAVE_READDIR_R_3 |
100 |
- while(!readdir_r(dd, &result, &dent) && dent) { |
|
100 |
+ while(!readdir_r(dd, (struct dirent *) &result, &dent) && dent) { |
|
101 | 101 |
#elif defined(HAVE_READDIR_R_2) |
102 |
- while((dent = (struct dirent *) readdir_r(dd, &result))) { |
|
102 |
+ while((dent = (struct dirent *) readdir_r(dd, (struct dirent *) &result))) { |
|
103 | 103 |
#else |
104 | 104 |
while((dent = readdir(dd))) { |
105 | 105 |
#endif |
... | ... |
@@ -44,6 +44,12 @@ |
44 | 44 |
pthread_mutex_t cli_gentemp_mutex = PTHREAD_MUTEX_INITIALIZER; |
45 | 45 |
#endif |
46 | 46 |
|
47 |
+#if defined(HAVE_READDIR_R_3) || defined(HAVE_READDIR_R_2) |
|
48 |
+#ifdef C_SOLARIS |
|
49 |
+#include <limits.h> |
|
50 |
+#endif |
|
51 |
+#endif |
|
52 |
+ |
|
47 | 53 |
#include "clamav.h" |
48 | 54 |
#include "others.h" |
49 | 55 |
#include "md5.h" |
... | ... |
@@ -374,8 +380,12 @@ int cli_rmdirs(const char *dirname) |
374 | 374 |
DIR *dd; |
375 | 375 |
struct dirent *dent; |
376 | 376 |
#if defined(HAVE_READDIR_R_3) || defined(HAVE_READDIR_R_2) |
377 |
+#ifdef C_SOLARIS |
|
378 |
+ char result[sizeof(struct dirent) + MAX_PATH + 1]; |
|
379 |
+#else |
|
377 | 380 |
struct dirent result; |
378 | 381 |
#endif |
382 |
+#endif |
|
379 | 383 |
struct stat maind, statbuf; |
380 | 384 |
char *fname; |
381 | 385 |
|
... | ... |
@@ -386,9 +396,9 @@ int cli_rmdirs(const char *dirname) |
386 | 386 |
if(!rmdir(dirname)) break; |
387 | 387 |
|
388 | 388 |
#ifdef HAVE_READDIR_R_3 |
389 |
- while(!readdir_r(dd, &result, &dent) && dent) { |
|
389 |
+ while(!readdir_r(dd, (struct dirent *) &result, &dent) && dent) { |
|
390 | 390 |
#elif defined(HAVE_READDIR_R_2) |
391 |
- while((dent = (struct dirent *) readdir_r(dd, &result))) { |
|
391 |
+ while((dent = (struct dirent *) readdir_r(dd, (struct dirent *) &result))) { |
|
392 | 392 |
#else |
393 | 393 |
while((dent = readdir(dd))) { |
394 | 394 |
#endif |
... | ... |
@@ -39,6 +39,12 @@ |
39 | 39 |
#include "str.h" |
40 | 40 |
#include "defaults.h" |
41 | 41 |
|
42 |
+#if defined(HAVE_READDIR_R_3) || defined(HAVE_READDIR_R_2) |
|
43 |
+#ifdef C_SOLARIS |
|
44 |
+#include <limits.h> |
|
45 |
+#endif |
|
46 |
+#endif |
|
47 |
+ |
|
42 | 48 |
/* TODO: clean up the code */ |
43 | 49 |
|
44 | 50 |
static int cli_ac_addsig(struct cl_node *root, const char *virname, const char *hexsig, int sigid, int parts, int partno, unsigned short type, unsigned int mindist, unsigned int maxdist, char *offset, unsigned short target) |
... | ... |
@@ -730,8 +736,12 @@ int cl_loaddbdir(const char *dirname, struct cl_node **root, unsigned int *signo |
730 | 730 |
DIR *dd; |
731 | 731 |
struct dirent *dent; |
732 | 732 |
#if defined(HAVE_READDIR_R_3) || defined(HAVE_READDIR_R_2) |
733 |
+#ifdef C_SOLARIS |
|
734 |
+ char result[sizeof(struct dirent) + MAX_PATH + 1]; |
|
735 |
+#else |
|
733 | 736 |
struct dirent result; |
734 | 737 |
#endif |
738 |
+#endif |
|
735 | 739 |
char *dbfile; |
736 | 740 |
int ret; |
737 | 741 |
|
... | ... |
@@ -744,9 +754,9 @@ int cl_loaddbdir(const char *dirname, struct cl_node **root, unsigned int *signo |
744 | 744 |
cli_dbgmsg("Loading databases from %s\n", dirname); |
745 | 745 |
|
746 | 746 |
#ifdef HAVE_READDIR_R_3 |
747 |
- while(!readdir_r(dd, &result, &dent) && dent) { |
|
747 |
+ while(!readdir_r(dd, (struct dirent *) &result, &dent) && dent) { |
|
748 | 748 |
#elif defined(HAVE_READDIR_R_2) |
749 |
- while((dent = (struct dirent *) readdir_r(dd, &result))) { |
|
749 |
+ while((dent = (struct dirent *) readdir_r(dd, (struct dirent *) &result))) { |
|
750 | 750 |
#else |
751 | 751 |
while((dent = readdir(dd))) { |
752 | 752 |
#endif |
... | ... |
@@ -793,10 +803,14 @@ const char *cl_retdbdir(void) |
793 | 793 |
int cl_statinidir(const char *dirname, struct cl_stat *dbstat) |
794 | 794 |
{ |
795 | 795 |
DIR *dd; |
796 |
- struct dirent *dent; |
|
796 |
+ const struct dirent *dent; |
|
797 | 797 |
#if defined(HAVE_READDIR_R_3) || defined(HAVE_READDIR_R_2) |
798 |
+#ifdef C_SOLARIS |
|
799 |
+ char result[sizeof(struct dirent) + MAX_PATH + 1]; |
|
800 |
+#else |
|
798 | 801 |
struct dirent result; |
799 | 802 |
#endif |
803 |
+#endif |
|
800 | 804 |
char *fname; |
801 | 805 |
|
802 | 806 |
|
... | ... |
@@ -817,9 +831,9 @@ int cl_statinidir(const char *dirname, struct cl_stat *dbstat) |
817 | 817 |
cli_dbgmsg("Stat()ing files in %s\n", dirname); |
818 | 818 |
|
819 | 819 |
#ifdef HAVE_READDIR_R_3 |
820 |
- while(!readdir_r(dd, &result, &dent) && dent) { |
|
820 |
+ while(!readdir_r(dd, (struct dirent *) &result, &dent) && dent) { |
|
821 | 821 |
#elif defined(HAVE_READDIR_R_2) |
822 |
- while((dent = (struct dirent *) readdir_r(dd, &result))) { |
|
822 |
+ while((dent = (struct dirent *) readdir_r(dd, (struct dirent *) &result))) { |
|
823 | 823 |
#else |
824 | 824 |
while((dent = readdir(dd))) { |
825 | 825 |
#endif |
... | ... |
@@ -854,8 +868,12 @@ int cl_statchkdir(const struct cl_stat *dbstat) |
854 | 854 |
DIR *dd; |
855 | 855 |
struct dirent *dent; |
856 | 856 |
#if defined(HAVE_READDIR_R_3) || defined(HAVE_READDIR_R_2) |
857 |
+#ifdef C_SOLARIS |
|
858 |
+ char result[sizeof(struct dirent) + MAX_PATH + 1]; |
|
859 |
+#else |
|
857 | 860 |
struct dirent result; |
858 | 861 |
#endif |
862 |
+#endif |
|
859 | 863 |
struct stat sb; |
860 | 864 |
int i, found; |
861 | 865 |
char *fname; |
... | ... |
@@ -874,9 +892,9 @@ int cl_statchkdir(const struct cl_stat *dbstat) |
874 | 874 |
cli_dbgmsg("Stat()ing files in %s\n", dbstat->dir); |
875 | 875 |
|
876 | 876 |
#ifdef HAVE_READDIR_R_3 |
877 |
- while(!readdir_r(dd, &result, &dent) && dent) { |
|
877 |
+ while(!readdir_r(dd, (struct dirent *) &result, &dent) && dent) { |
|
878 | 878 |
#elif defined(HAVE_READDIR_R_2) |
879 |
- while((dent = (struct dirent *) readdir_r(dd, &result))) { |
|
879 |
+ while((dent = (struct dirent *) readdir_r(dd, (struct dirent *) &result))) { |
|
880 | 880 |
#else |
881 | 881 |
while((dent = readdir(dd))) { |
882 | 882 |
#endif |
... | ... |
@@ -77,6 +77,13 @@ extern int cli_mbox(const char *dir, int desc, unsigned int options); /* FIXME * |
77 | 77 |
#include <bzlib.h> |
78 | 78 |
#endif |
79 | 79 |
|
80 |
+#if defined(HAVE_READDIR_R_3) || defined(HAVE_READDIR_R_2) |
|
81 |
+#ifdef C_SOLARIS |
|
82 |
+#include <limits.h> |
|
83 |
+#endif |
|
84 |
+#endif |
|
85 |
+ |
|
86 |
+ |
|
80 | 87 |
#define SCAN_ARCHIVE (options & CL_SCAN_ARCHIVE) |
81 | 88 |
#define SCAN_MAIL (options & CL_SCAN_MAIL) |
82 | 89 |
#define SCAN_OLE2 (options & CL_SCAN_OLE2) |
... | ... |
@@ -752,17 +759,21 @@ static int cli_scandir(const char *dirname, const char **virname, long int *scan |
752 | 752 |
DIR *dd; |
753 | 753 |
struct dirent *dent; |
754 | 754 |
#if defined(HAVE_READDIR_R_3) || defined(HAVE_READDIR_R_2) |
755 |
+#ifdef C_SOLARIS |
|
756 |
+ char result[sizeof(struct dirent) + MAX_PATH + 1]; |
|
757 |
+#else |
|
755 | 758 |
struct dirent result; |
756 | 759 |
#endif |
760 |
+#endif |
|
757 | 761 |
struct stat statbuf; |
758 | 762 |
char *fname; |
759 | 763 |
|
760 | 764 |
|
761 | 765 |
if((dd = opendir(dirname)) != NULL) { |
762 | 766 |
#ifdef HAVE_READDIR_R_3 |
763 |
- while(!readdir_r(dd, &result, &dent) && dent) { |
|
767 |
+ while(!readdir_r(dd, (struct dirent *) &result, &dent) && dent) { |
|
764 | 768 |
#elif defined(HAVE_READDIR_R_2) |
765 |
- while((dent = (struct dirent *) readdir_r(dd, &result))) { |
|
769 |
+ while((dent = (struct dirent *) readdir_r(dd, (struct dirent *) &result))) { |
|
766 | 770 |
#else |
767 | 771 |
while((dent = readdir(dd))) { |
768 | 772 |
#endif |
... | ... |
@@ -812,8 +823,12 @@ static int cli_vba_scandir(const char *dirname, const char **virname, long int * |
812 | 812 |
DIR *dd; |
813 | 813 |
struct dirent *dent; |
814 | 814 |
#if defined(HAVE_READDIR_R_3) || defined(HAVE_READDIR_R_2) |
815 |
+#ifdef C_SOLARIS |
|
816 |
+ char result[sizeof(struct dirent) + MAX_PATH + 1]; |
|
817 |
+#else |
|
815 | 818 |
struct dirent result; |
816 | 819 |
#endif |
820 |
+#endif |
|
817 | 821 |
struct stat statbuf; |
818 | 822 |
char *fname, *fullname; |
819 | 823 |
unsigned char *data; |
... | ... |
@@ -910,9 +925,9 @@ static int cli_vba_scandir(const char *dirname, const char **virname, long int * |
910 | 910 |
|
911 | 911 |
if((dd = opendir(dirname)) != NULL) { |
912 | 912 |
#ifdef HAVE_READDIR_R_3 |
913 |
- while(!readdir_r(dd, &result, &dent) && dent) { |
|
913 |
+ while(!readdir_r(dd, (struct dirent *) &result, &dent) && dent) { |
|
914 | 914 |
#elif defined(HAVE_READDIR_R_2) |
915 |
- while((dent = (struct dirent *) readdir_r(dd, &result))) { |
|
915 |
+ while((dent = (struct dirent *) readdir_r(dd, (struct dirent *) &result))) { |
|
916 | 916 |
#else |
917 | 917 |
while((dent = readdir(dd))) { |
918 | 918 |
#endif |