Browse code

Freshclam fix

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

Tomasz Kojm authored on 2003/11/02 09:08:18
Showing 2 changed files
... ...
@@ -1,3 +1,8 @@
1
+Sun Nov  2 01:07:46 CET 2003 (tk)
2
+---------------------------------
3
+  * freshclam: do not use IP address in database request (thanks to Luca
4
+	       'NERvOus' Gibelli)
5
+
1 6
 Sat Nov  1 04:14:14 CET 2003 (tk)
2 7
 ---------------------------------
3 8
   * clamd: scanner: close a whole file stream and not only a file descriptor;
... ...
@@ -58,12 +58,15 @@ int downloadmanager(const struct optstruct *opt, const char *hostname)
58 58
     logg("SECURITY WARNING: NO SUPPORT FOR DIGITAL SIGNATURES\n");
59 59
 #endif
60 60
 
61
+    memset(ipaddr, 0, sizeof(ipaddr));
62
+
61 63
     if((ret = downloaddb(DB1NAME, "main.cvd", hostname, ipaddr, &signo, opt)) > 50)
62 64
 	return ret;
63 65
     else if(ret == 0)
64 66
 	updated = 1;
65 67
 
66
-    if((ret = downloaddb(DB2NAME, "daily.cvd", ipaddr, NULL, &signo, opt)) > 50)
68
+    /* if ipaddr[0] != 0 it will use ipaddr to connect to the web host */
69
+    if((ret = downloaddb(DB2NAME, "daily.cvd", hostname, ipaddr, &signo, opt)) > 50)
67 70
 	return ret;
68 71
     else if(ret == 0)
69 72
 	updated = 1;
... ...
@@ -134,15 +137,18 @@ int downloaddb(const char *localname, const char *remotename, const char *hostna
134 134
     if(proxy)
135 135
 	mprintf("Connecting via %s\n", proxy);
136 136
 
137
-    hostfd = wwwconnect(hostname, proxy, ipaddr);
137
+    if(ip[0])
138
+	hostfd = wwwconnect(ip, proxy, NULL); /* we use ip to connect */
139
+    else
140
+	hostfd = wwwconnect(hostname, proxy, ipaddr);
138 141
 
139 142
     if(hostfd < 0) {
140
-	mprintf("@Connection with %s (%s) failed.\n", hostname, ipaddr);
143
+	mprintf("@Connection with %s (IP: %s) failed.\n", hostname, ipaddr);
141 144
 	return 52;
142 145
     } else
143 146
 	mprintf("*Connected to %s (%s).\n", hostname, ipaddr);
144 147
 
145
-    if(ip)
148
+    if(!ip[0])
146 149
 	strcpy(ip, ipaddr);
147 150
 
148 151
     if(!(remote = remote_cvdhead(remotename, hostfd, hostname, proxy, user))) {
... ...
@@ -294,7 +300,7 @@ int wwwconnect(const char *server, const char *proxy, char *ip)
294 294
     name.sin_port = htons(port);
295 295
 
296 296
     if(connect(socketfd, (struct sockaddr *) &name, sizeof(struct sockaddr_in)) == -1) {
297
-	mprintf("@Can't connect to port %d of host %s (IP: %s)\n", port, hostpt, ipaddr);
297
+	mprintf("@Can't connect to port %d of host %s (%s)\n", port, hostpt, ipaddr);
298 298
 	close(socketfd);
299 299
 	if(proxycpy)
300 300
 	    free(proxycpy);