git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@471 77e5149b-7576-45b1-b177-96237e5ba77b
Tomasz Kojm authored on 2004/04/05 22:30:09... | ... |
@@ -1,3 +1,8 @@ |
1 |
+Mon Apr 5 15:39:55 CEST 2004 (tk) |
|
2 |
+---------------------------------- |
|
3 |
+ * clamd: respect TCPAddr in stream scanner (problem reported by |
|
4 |
+ Youza Youzovic <youza*post.cz>) |
|
5 |
+ |
|
1 | 6 |
Mon Apr 5 13:19:02 BST 2004 (njh) |
2 | 7 |
---------------------------------- |
3 | 8 |
* libclamav: Scan attachments with no filename (suggestion by Trog) |
... | ... |
@@ -29,10 +29,10 @@ |
29 | 29 |
#include <sys/time.h> |
30 | 30 |
#include <sys/wait.h> |
31 | 31 |
#include <dirent.h> |
32 |
-#include <sys/types.h> |
|
33 | 32 |
#include <sys/socket.h> |
34 | 33 |
#include <netinet/in.h> |
35 |
-#include <errno.h> |
|
34 |
+#include <arpa/inet.h> |
|
35 |
+#include <netdb.h> |
|
36 | 36 |
#include <clamav.h> |
37 | 37 |
|
38 | 38 |
#include "cfgparser.h" |
... | ... |
@@ -198,8 +198,9 @@ int scanstream(int odesc, unsigned long int *scanned, const struct cl_node *root |
198 | 198 |
long int size = 0, maxsize = 0; |
199 | 199 |
short bound = 0; |
200 | 200 |
const char *virname; |
201 |
- char buff[32768]; |
|
201 |
+ char buff[FILEBUFF]; |
|
202 | 202 |
struct sockaddr_in server; |
203 |
+ struct hostent *he; |
|
203 | 204 |
struct cfgstruct *cpt; |
204 | 205 |
FILE *tmp = NULL; |
205 | 206 |
|
... | ... |
@@ -210,7 +211,16 @@ int scanstream(int odesc, unsigned long int *scanned, const struct cl_node *root |
210 | 210 |
memset((char *) &server, 0, sizeof(server)); |
211 | 211 |
server.sin_family = AF_INET; |
212 | 212 |
server.sin_port = htons(port); |
213 |
- server.sin_addr.s_addr = INADDR_ANY; |
|
213 |
+ |
|
214 |
+ if((cpt = cfgopt(copt, "TCPAddr"))) { |
|
215 |
+ if ((he = gethostbyname(cpt->strarg)) == 0) { |
|
216 |
+ logg("!gethostbyname(%s) error: %s\n", cpt->strarg); |
|
217 |
+ mdprintf(odesc, "gethostbyname(%s) ERROR\n", cpt->strarg); |
|
218 |
+ return -1; |
|
219 |
+ } |
|
220 |
+ server.sin_addr = *(struct in_addr *) he->h_addr_list[0]; |
|
221 |
+ } else |
|
222 |
+ server.sin_addr.s_addr = INADDR_ANY; |
|
214 | 223 |
|
215 | 224 |
if((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) |
216 | 225 |
continue; |
... | ... |
@@ -232,8 +242,8 @@ int scanstream(int odesc, unsigned long int *scanned, const struct cl_node *root |
232 | 232 |
} |
233 | 233 |
|
234 | 234 |
if(!bound && !portscan) { |
235 |
- mdprintf(odesc, "ERROR\n"); |
|
236 | 235 |
logg("!ScanStream: Can't find any free port.\n"); |
236 |
+ mdprintf(odesc, "Can't find any free port ERROR\n"); |
|
237 | 237 |
return -1; |
238 | 238 |
} else { |
239 | 239 |
listen(sockfd, 1); |
... | ... |
@@ -243,11 +253,11 @@ int scanstream(int odesc, unsigned long int *scanned, const struct cl_node *root |
243 | 243 |
retval = poll_fd(sockfd, timeout); |
244 | 244 |
switch (retval) { |
245 | 245 |
case 0: /* timeout */ |
246 |
- mdprintf(sockfd, "ERROR\n"); |
|
246 |
+ mdprintf(sockfd, "Accept timeout ERROR\n"); |
|
247 | 247 |
logg("!ScanStream: accept timeout.\n"); |
248 | 248 |
return -1; |
249 | 249 |
case -1: |
250 |
- mdprintf(sockfd, "ERROR\n"); |
|
250 |
+ mdprintf(sockfd, "accept poll ERROR\n"); |
|
251 | 251 |
logg("!ScanStream: accept poll failed.\n"); |
252 | 252 |
return -1; |
253 | 253 |
} |