Browse code

Fix compilation error in SESSION mode

git-svn: trunk@2477

Nigel Horne authored on 2006/11/04 06:30:24
Showing 2 changed files
... ...
@@ -1,3 +1,7 @@
1
+Fri Nov  3 21:28:13 GMT 2006 (njh)
2
+----------------------------------
3
+  * clamav-milter:	Fix compilation error in session mode, bug 115
4
+
1 5
 Fri Nov  3 19:47:42 GMT 2006 (njh)
2 6
 ----------------------------------
3 7
   * libclamav/mbox.c:	Partial fix for bug 33
... ...
@@ -24,7 +24,7 @@
24 24
  *
25 25
  * For installation instructions see the file INSTALL that came with this file
26 26
  */
27
-static	char	const	rcsid[] = "$Id: clamav-milter.c,v 1.295 2006/10/30 14:20:36 njh Exp $";
27
+static	char	const	rcsid[] = "$Id: clamav-milter.c,v 1.296 2006/11/03 21:27:29 njh Exp $";
28 28
 
29 29
 #define	CM_VERSION	"devel-301006"
30 30
 
... ...
@@ -152,8 +152,8 @@ typedef	unsigned int	in_addr_t;
152 152
 #define	VERSION_LENGTH	128
153 153
 #define	DEFAULT_TIMEOUT	120
154 154
 
155
-/*#define	SESSION	/*
156
-		 * Keep one command connection open to clamd, otherwise a new
155
+/*#define	SESSION*/
156
+		/* Keep one command connection open to clamd, otherwise a new
157 157
 		 * command connection is created for each new email
158 158
 		 *
159 159
 		 * FIXME: When SESSIONS are open, freshclam can hang when
... ...
@@ -1275,7 +1275,7 @@ main(int argc, char **argv)
1275 1275
 		numServers = 1;
1276 1276
 	} else if(((cpt = cfgopt(copt, "LocalSocket")) != NULL) && cpt->enabled) {
1277 1277
 #ifdef	SESSION
1278
-		struct sockaddr_un server;
1278
+		struct sockaddr_un sun;
1279 1279
 #endif
1280 1280
 		char *sockname = NULL;
1281 1281
 
... ...
@@ -1327,9 +1327,9 @@ main(int argc, char **argv)
1327 1327
 #endif
1328 1328
 
1329 1329
 #ifdef	SESSION
1330
-		memset((char *)&server, 0, sizeof(struct sockaddr_un));
1331
-		server.sun_family = AF_UNIX;
1332
-		strncpy(server.sun_path, localSocket, sizeof(server.sun_path));
1330
+		memset((char *)&sun, 0, sizeof(struct sockaddr_un));
1331
+		sun.sun_family = AF_UNIX;
1332
+		strncpy(sun.sun_path, localSocket, sizeof(sun.sun_path));
1333 1333
 
1334 1334
 		sessions = (struct session *)cli_malloc(sizeof(struct session));
1335 1335
 		if((sessions[0].sock = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
... ...
@@ -1340,7 +1340,7 @@ main(int argc, char **argv)
1340 1340
 				cfgfile);
1341 1341
 			return EX_CONFIG;
1342 1342
 		}
1343
-		if(connect(sessions[0].sock, (struct sockaddr *)&server, sizeof(struct sockaddr_un)) < 0) {
1343
+		if(connect(sessions[0].sock, (struct sockaddr *)&sun, sizeof(struct sockaddr_un)) < 0) {
1344 1344
 			perror(localSocket);
1345 1345
 			return EX_UNAVAILABLE;
1346 1346
 		}
... ...
@@ -1876,7 +1876,7 @@ createSession(unsigned int s)
1876 1876
 	proto = getprotobyname("tcp");
1877 1877
 	if(proto == NULL) {
1878 1878
 		fputs("Unknown prototol tcp, check /etc/protocols\n", stderr);
1879
-		ret = -1;
1879
+		fd = ret = -1;
1880 1880
 	} else if((fd = socket(AF_INET, SOCK_STREAM, proto->p_proto)) < 0) {
1881 1881
 		perror("socket");
1882 1882
 		ret = -1;
... ...
@@ -3777,7 +3777,11 @@ clamfi_free(struct privdata *privdata, int keep)
3777 3777
 
3778 3778
 		if(keep) {
3779 3779
 			memset(privdata, '\0', sizeof(struct privdata));
3780
+#ifdef	SESSION
3781
+			privdata->dataSocket = -1;
3782
+#else
3780 3783
 			privdata->dataSocket = privdata->cmdSocket = -1;
3784
+#endif
3781 3785
 		} else
3782 3786
 			free(privdata);
3783 3787
 	}