Browse code

Plug leak on SPF error handling

git-svn: trunk@3232

Nigel Horne authored on 2007/09/20 20:07:00
Showing 2 changed files
... ...
@@ -1,3 +1,7 @@
1
+Thu Sep 20 11:21:14 BST 2007 (njh)
2
+----------------------------------
3
+  * clamav-milter/clamav-milter.c:	Plug leak on SPF error handling
4
+
1 5
 Tue Sep 18 19:50:33 CEST 2007 (tk)
2 6
 ----------------------------------
3 7
   * libclamav/matcher-ac.c: properly handle alternatives in the new approach
... ...
@@ -33,7 +33,7 @@
33 33
  */
34 34
 static	char	const	rcsid[] = "$Id: clamav-milter.c,v 1.312 2007/02/12 22:24:21 njh Exp $";
35 35
 
36
-#define	CM_VERSION	"devel-20080902"
36
+#define	CM_VERSION	"devel-20080920"
37 37
 
38 38
 #if HAVE_CONFIG_H
39 39
 #include "clamav-config.h"
... ...
@@ -81,9 +81,6 @@ static	char	const	rcsid[] = "$Id: clamav-milter.c,v 1.312 2007/02/12 22:24:21 nj
81 81
 #include <pthread.h>
82 82
 #include <sys/time.h>
83 83
 #include <signal.h>
84
-#if	HAVE_REGEX_H
85
-#include <regex.h>
86
-#endif
87 84
 #include <fcntl.h>
88 85
 #include <pwd.h>
89 86
 #include <grp.h>
... ...
@@ -203,6 +200,7 @@ typedef	unsigned int	in_addr_t;
203 203
  *	address
204 204
  * TODO: optionally use zlib to compress data sent to remote hosts
205 205
  * TODO: Finish IPv6 support (serverIPs array and SPF are IPv4 only)
206
+ * TODO: Check domainkeys as well as SPF for phish false positives
206 207
  */
207 208
 
208 209
 struct header_node_t {
... ...
@@ -6281,7 +6279,7 @@ spf(struct privdata *privdata, table_t *prevhosts)
6281 6281
 			char *record;
6282 6282
 			struct in_addr remote_ip;	/* IP connecting to us */
6283 6283
 
6284
-			logg("#%s(%s): SPF record %s\n",
6284
+			logg("*%s(%s): SPF record %s\n",
6285 6285
 				host, privdata->ip, txt);
6286 6286
 #ifdef HAVE_INET_NTOP
6287 6287
 			/* IPv4 address ? */
... ...
@@ -6316,11 +6314,15 @@ spf(struct privdata *privdata, table_t *prevhosts)
6316 6316
 
6317 6317
 #ifdef HAVE_INET_NTOP
6318 6318
 					/* IPv4 address ? */
6319
-					if(inet_pton(AF_INET, ip, &spf_range) <= 0)
6319
+					if(inet_pton(AF_INET, ip, &spf_range) <= 0) {
6320
+						free(record);
6320 6321
 						continue;
6322
+					}
6321 6323
 #else
6322
-					if(inet_aton(ip, &spf_range) == 0)
6324
+					if(inet_aton(ip, &spf_range) == 0) {
6325
+						free(record);
6323 6326
 						continue;
6327
+					}
6324 6328
 #endif
6325 6329
 					mask = MAKEMASK(preflen);
6326 6330
 					if((ntohl(remote_ip.s_addr) & mask) == (ntohl(spf_range.s_addr) & mask)) {