Browse code

Don't pass empty arguments to inet_ntop

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

Nigel Horne authored on 2004/07/09 07:26:46
Showing 3 changed files
... ...
@@ -1,3 +1,10 @@
1
+Thu Jul  8 23:23:34 BST 2004 (njh)
2
+----------------------------------
3
+  * clamav-milter:	Validate arguments given to inet_ntop. This
4
+		is needed for machines that can't always get hostnames
5
+		right, presumably broken hosts file or DNS or possibly
6
+		connecting to sendmail incorrectly
7
+
1 8
 Thu Jul  8 19:12:14 CEST 2004 (tk)
2 9
 ----------------------------------
3 10
   * libclamav: read .db3 files from cvd
... ...
@@ -86,6 +86,9 @@ Installations for RedHat Linux and it's derivatives such as YellowDog:
86 86
 	chown clamav /var/run/clamav	(if you use User clamav in clamav.conf)
87 87
 	chmod 700 /var/run/clamav
88 88
 
89
+	Where /var/run/spamass.sock is the location of the spamass-milt
90
+	socket file (on some systems it is in /var/run/sendmail/spamass.sock).
91
+
89 92
 You may find INPUT_MAIL_FILTERS is not needed on your machine, however it
90 93
 is recommended by the Sendmail documentation and I recommend going along
91 94
 with that.
... ...
@@ -417,6 +420,7 @@ Changes
417 417
 			already exists
418 418
 0.74	29/6/04	Up-issued
419 419
 0.74a	29/6/04	Allow the child timeout to be configurable
420
+0.74b	8/7/04	Validate the arguments to inet_ntop
420 421
 
421 422
 BUG REPORTS
422 423
 
... ...
@@ -26,6 +26,9 @@
26 26
  *
27 27
  * Change History:
28 28
  * $Log: clamav-milter.c,v $
29
+ * Revision 1.103  2004/07/08 22:22:39  nigelhorne
30
+ * Don't pass empty arguments to inet_ntop
31
+ *
29 32
  * Revision 1.102  2004/06/29 15:26:14  nigelhorne
30 33
  * Support the --timeout argument
31 34
  *
... ...
@@ -317,9 +320,9 @@
317 317
  * Revision 1.6  2003/09/28 16:37:23  nigelhorne
318 318
  * Added -f flag use MaxThreads if --max-children not set
319 319
  */
320
-static	char	const	rcsid[] = "$Id: clamav-milter.c,v 1.102 2004/06/29 15:26:14 nigelhorne Exp $";
320
+static	char	const	rcsid[] = "$Id: clamav-milter.c,v 1.103 2004/07/08 22:22:39 nigelhorne Exp $";
321 321
 
322
-#define	CM_VERSION	"0.74a"
322
+#define	CM_VERSION	"0.74b"
323 323
 
324 324
 /*#define	CONFDIR	"/usr/local/etc"*/
325 325
 
... ...
@@ -1414,7 +1417,7 @@ clamfi_connect(SMFICTX *ctx, char *hostname, _SOCK_ADDR *hostaddr)
1414 1414
 			syslog(LOG_ERR, "clamfi_connect: hostname is null");
1415 1415
 		return cl_error;
1416 1416
 	}
1417
-	if(hostaddr == NULL)
1417
+	if((hostaddr == NULL) || (&(((struct sockaddr_in *)(hostaddr))->sin_addr) == NULL))
1418 1418
 		/*
1419 1419
 		 * According to the sendmail API hostaddr is NULL if
1420 1420
 		 * "the type is not supported in the current version". What
... ...
@@ -1469,7 +1472,8 @@ clamfi_connect(SMFICTX *ctx, char *hostname, _SOCK_ADDR *hostaddr)
1469 1469
 		}
1470 1470
 
1471 1471
 #ifdef HAVE_INET_NTOP
1472
-		if(inet_ntop(AF_INET, (struct in_addr *)hp->h_addr, ip, sizeof(ip)) == NULL) {
1472
+		if(hp && hp->h_addr &&
1473
+		   (inet_ntop(AF_INET, (struct in_addr *)hp->h_addr, ip, sizeof(ip)) == NULL)) {
1473 1474
 			perror(hp->h_name);
1474 1475
 			/*if(use_syslog)
1475 1476
 				syslog(LOG_WARNING, "Can't get IP address for (%s)", hp->h_name);