diff src/dnsbl.cpp @ 186:2a80c9b5d2c9

fix null pointer dereference from missing HELO command
author carl
date Sat, 10 Nov 2007 10:20:54 -0800
parents 505283ab296c
children f0eda59e8afd
line wrap: on
line diff
--- a/src/dnsbl.cpp	Sat Oct 13 17:42:30 2007 -0700
+++ b/src/dnsbl.cpp	Sat Nov 10 10:20:54 2007 -0800
@@ -64,7 +64,6 @@
 
 
 extern "C" {
-	#include <libmilter/mfapi.h>
 	sfsistat mlfi_connect(SMFICTX *ctx, char *hostname, _SOCK_ADDR *hostaddr);
 	sfsistat mlfi_helo(SMFICTX * ctx, char *helohost);
 	sfsistat mlfi_envfrom(SMFICTX *ctx, char **argv);
@@ -425,7 +424,16 @@
 	}
 }
 
-#define MLFIPRIV	((struct mlfiPriv *) smfi_getpriv(ctx))
+
+mlfiPriv* fetch_priv_from_ctx(SMFICTX *ctx);
+mlfiPriv* fetch_priv_from_ctx(SMFICTX *ctx)
+{
+    mlfiPriv *priv = (struct mlfiPriv *)smfi_getpriv(ctx);
+    priv.ctx = ctx;
+    return priv;
+}
+#define MLFIPRIV    fetch_priv_from_ctx(ctx)
+
 
 
 ////////////////////////////////////////////////
@@ -559,6 +567,11 @@
 //
 int dns_interface(mlfiPriv &priv, char *question, bool maybe_ip, ns_map *nameservers);
 int dns_interface(mlfiPriv &priv, char *question, bool maybe_ip, ns_map *nameservers) {
+    // tell sendmail we are still working
+    #if _FFR_SMFI_PROGRESS
+        smfi_progress(priv.ctx);
+    #endif
+
 	// this part can be done without locking the resolver mutex. Each
 	// milter thread is talking over its own socket to a separate resolver
 	// process, which does the actual dns resolution.
@@ -972,7 +985,7 @@
 sfsistat mlfi_helo(SMFICTX * ctx, char *helohost)
 {
 	mlfiPriv &priv	   = *MLFIPRIV;
-	priv.helo		   = strdup(helohost);
+	priv.helo		   = (helohost) ? strdup(helohost) : strdup("missing");
 	return SMFIS_CONTINUE;
 }