Browse code

Handle empty hostname or hostaddr

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

Nigel Horne authored on 2003/11/25 14:59:36
Showing 3 changed files
... ...
@@ -1,3 +1,8 @@
1
+Tue Nov 25 11:28:28 IST 2003 (njh)
2
+----------------------------------
3
+  * clamav-milter: Handle empty hostname or hostaddr
4
+	Thanks to Michael Dankov <misha@btrc.ru> for the idea
5
+
1 6
 Mon Nov 24 17:18:03 CET 2003 (tk)
2 7
 ---------------------------------
3 8
   * libclamav: cvd.c: small cleanups
... ...
@@ -154,6 +154,8 @@ Changes
154 154
 		Added quarantine support
155 155
 0.65c	24/11/03 Support AllowSupplementaryGroups
156 156
 		Fix warning about root usage
157
+0.65d	25/11/03 Handle empty hostname or hostaddr
158
+		Fix based on a submission by Michael Dankov <misha@btrc.ru>
157 159
 
158 160
 BUG REPORTS
159 161
 
... ...
@@ -158,9 +158,14 @@
158 158
  *			Added quarantine support
159 159
  *	0.65c	24/11/03 Support AllowSupplementaryGroups
160 160
  *			Fix warning about root usage
161
+ *	0.65d	25/11/03 Handle empty hostname or hostaddr
162
+ *			Fix based on a submission by Michael Dankov <misha@btrc.ru>
161 163
  *
162 164
  * Change History:
163 165
  * $Log: clamav-milter.c,v $
166
+ * Revision 1.23  2003/11/25 05:56:43  nigelhorne
167
+ * Handle empty hostname or hostaddr
168
+ *
164 169
  * Revision 1.22  2003/11/24 04:48:44  nigelhorne
165 170
  * Support AllowSupplementaryGroups
166 171
  *
... ...
@@ -212,9 +217,9 @@
212 212
  * Revision 1.6  2003/09/28 16:37:23  nigelhorne
213 213
  * Added -f flag use MaxThreads if --max-children not set
214 214
  */
215
-static	char	const	rcsid[] = "$Id: clamav-milter.c,v 1.22 2003/11/24 04:48:44 nigelhorne Exp $";
215
+static	char	const	rcsid[] = "$Id: clamav-milter.c,v 1.23 2003/11/25 05:56:43 nigelhorne Exp $";
216 216
 
217
-#define	CM_VERSION	"0.65c"
217
+#define	CM_VERSION	"0.65d"
218 218
 
219 219
 /*#define	CONFDIR	"/usr/local/etc"*/
220 220
 
... ...
@@ -805,11 +810,26 @@ static sfsistat
805 805
 clamfi_connect(SMFICTX *ctx, char *hostname, _SOCK_ADDR *hostaddr)
806 806
 {
807 807
 	char buf[INET_ADDRSTRLEN];	/* IPv4 only */
808
-	const char *remoteIP = inet_ntop(AF_INET, &((struct sockaddr_in *)(hostaddr))->sin_addr, buf, sizeof(buf));
808
+	const char *remoteIP;
809 809
 
810
-#ifdef	CL_DEBUG
811
-	assert(remoteIP != NULL);
812
-#endif
810
+	if(hostname == NULL) {
811
+		if(use_syslog)
812
+			syslog(LOG_ERR, "clamfi_connect: hostname is null");
813
+		return cl_error;
814
+	}
815
+	if(hostaddr == NULL) {
816
+		if(use_syslog)
817
+			syslog(LOG_ERR, "clamfi_connect: hostaddr is null");
818
+		return cl_error;
819
+	}
820
+
821
+	remoteIP = inet_ntop(AF_INET, &((struct sockaddr_in *)(hostaddr))->sin_addr, buf, sizeof(buf));
822
+
823
+	if(remoteIP == NULL) {
824
+		if(use_syslog)
825
+			syslog(LOG_ERR, "clamfi_connect: remoteIP is null");
826
+		return cl_error;
827
+	}
813 828
 
814 829
 	if(use_syslog)
815 830
 		syslog(LOG_NOTICE, "clamfi_connect: connection from %s [%s]", hostname, remoteIP);
... ...
@@ -979,11 +999,11 @@ clamfi_envfrom(SMFICTX *ctx, char **argv)
979 979
 
980 980
 		if((privdata->cmdSocket = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
981 981
 			perror("socket");
982
-			return SMFIS_TEMPFAIL;
982
+			return cl_error;
983 983
 		}
984 984
 		if(connect(privdata->cmdSocket, (struct sockaddr *)&server, sizeof(struct sockaddr_in)) < 0) {
985 985
 			perror("connect");
986
-			return SMFIS_TEMPFAIL;
986
+			return cl_error;
987 987
 		}
988 988
 	}
989 989