Hello, All!

# freshclam -V
ClamAV 0.88/1275/Fri Feb  3 21:00:42 2006
# uname -mrsp
FreeBSD 5.4-RELEASE i386 i386

freshclam --help and man freshclam say:
--local-address=IP   -a IP           bind to IP for HTTP downloads

but this actually don't work.

If I set in fresclam.conf option LocalIPAddress

freshclam report error:
ERROR: Could not bind to local ip address '192.168.1.1': Bad file descriptor
WARNING: Using default client ip.

--------------

Patch to fix this bug:

--- manager.c.orig      Fri Feb  3 21:22:17 2006
+++ manager.c   Fri Feb  3 21:26:15 2006
@@ -148,8 +148,8 @@
     }
 #endif /* HAVE_RESOLV_H */

-    if(optl(opt, "localip")) {
-        localip = getargl(opt, "localip");
+    if(optl(opt, "local-address")) {
+        localip = getargl(opt, "local-address");
     } else if((cpt = cfgopt(copt, "LocalIPAddress"))) {
        localip = cpt->strarg;
     }
@@ -496,6 +496,12 @@
        strcpy(ip, "???");

     name.sin_family = AF_INET;
+
+    #ifdef PF_INET
+       socketfd = socket(PF_INET, SOCK_STREAM, 0);
+    #else
+       socketfd = socket(AF_INET, SOCK_STREAM, 0);
+    #endif

     if (localip) {
        if ((he = gethostbyname(localip)) == NULL) {
@@ -601,12 +607,6 @@

        name.sin_addr = *((struct in_addr *) host->h_addr_list[i]);
        name.sin_port = htons(port);
-
-#ifdef PF_INET
-       socketfd = socket(PF_INET, SOCK_STREAM, 0);
-#else
-       socketfd = socket(AF_INET, SOCK_STREAM, 0);
-#endif

        if(connect(socketfd, (struct sockaddr *) &name, sizeof(struct 
sockaddr_in)) == -1) {
            mprintf("Can't connect to port %d of host %s (IP: %s)\n", port, 
hostpt, ipaddr);
--- options.c.orig      Fri Feb  3 21:21:07 2006
+++ options.c   Fri Feb  3 21:21:18 2006
@@ -61,7 +61,7 @@
            {"no-dns", 0, 0, 0},
            {"checks", 1, 0, 'c'},
            {"http-proxy", 1, 0, 0},
-           {"client-address", 1, 0, 'a'},
+           {"local-address", 1, 0, 'a'},
            {"proxy-user", 1, 0, 0},
            {"daemon-notify", 2, 0, 0},
            {"on-update-execute", 1, 0, 0},

Problems was:
1. In call bind before socket and using uninitialized variable socketfd.
2. In 3 different names for option local-address

--
Anton Yuzhaninov, OSPF-RIPE

P. S. I've sent this report to [EMAIL PROTECTED] week ago, but have no 
response... 



_______________________________________________
http://lurker.clamav.net/list/clamav-devel.html

Reply via email to