diff src/dnsbl.cpp @ 286:9bd5388bf469 stable-6-0-40

Fix possible segfault in mlfi_connect, hostaddr might be null
author Carl Byington <carl@five-ten-sg.com>
date Wed, 05 Feb 2014 07:54:38 -0800
parents 896b9393d3f0
children bb69fdc3acaa
line wrap: on
line diff
--- a/src/dnsbl.cpp	Tue Dec 31 10:47:39 2013 -0800
+++ b/src/dnsbl.cpp	Wed Feb 05 07:54:38 2014 -0800
@@ -1149,7 +1149,7 @@
 {
     // allocate some private memory
     mlfiPriv *priv = new mlfiPriv;
-    if (hostaddr->sa_family == AF_INET) {
+    if (hostaddr && (hostaddr->sa_family == AF_INET)) {
         priv->ip = ((struct sockaddr_in *)hostaddr)->sin_addr.s_addr;
     }
     // save the private data
@@ -1234,6 +1234,7 @@
     // some version of sendmail allowed rcpt to:<> and passed it thru to the milters
     if (strcmp(loto, "<>") == 0) {
         smfi_setreply(ctx, (char*)"550", (char*)"5.7.1", (char*)"bogus recipient");
+        free((void*)loto);      // cppcheck static analysis found memory leak
         return SMFIS_REJECT;
     }
     // priv.mailaddr sending original message to loto