Mercurial > dnsbl
diff src/dnsbl.cpp @ 231:4d6bd04d93fa stable-6-0-22
Fix memory leak in suppressed auto whitelisting.
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Fri, 08 May 2009 15:17:52 -0700 |
parents | ad38575e98ca |
children | 5c3e9bf45bb5 |
line wrap: on
line diff
--- a/src/dnsbl.cpp Fri May 08 12:55:30 2009 -0700 +++ b/src/dnsbl.cpp Fri May 08 15:17:52 2009 -0700 @@ -298,6 +298,8 @@ void mlfiPriv::reset(bool final) { while (!delayer.empty()) { DELAYWHITEP dwp = delayer.front(); + const char *loto = dwp->get_loto(); + if (loto) free((void*)loto); delete dwp; delayer.pop_front(); } @@ -1138,11 +1140,11 @@ if (len >= max_local_size) w = NULL; // too big, pretend we don't have a whitelister // record it if we have a whitelister if (w) { - DELAYWHITEP dwp = new DELAYWHITE(loto, w, &con2); + DELAYWHITEP dwp = new DELAYWHITE(loto, w, &con2); // dwp takes ownership of the string priv.delayer.push_back(dwp); } else { - free((void*)loto); + free((void*)loto); // or we free it here } // accept the recipient @@ -1176,7 +1178,7 @@ sfsistat mlfi_header(SMFICTX* ctx, char* headerf, char* headerv) { mlfiPriv &priv = *MLFIPRIV; - // detect precedence:bulk for avoiding autowhitelisting + // headers that avoid autowhitelisting if (((strcasecmp(headerf, "precedence") == 0) && (strcasecmp(headerv, "bulk") == 0)) || ((strcasecmp(headerf, "content-type") == 0) && (strncasecmp(headerv, "multipart/report", 16) == 0))) { priv.allow_autowhitelisting = false; @@ -1196,8 +1198,8 @@ // delayed autowhitelisting while (!priv.delayer.empty()) { DELAYWHITEP dwp = priv.delayer.front(); + const char *loto = dwp->get_loto(); if (priv.allow_autowhitelisting) { - const char *loto = dwp->get_loto(); WHITELISTERP w = dwp->get_w(); CONTEXTP con2 = dwp->get_con(); if (debug_syslog > 1) { @@ -1208,6 +1210,14 @@ } w->sent(loto); // don't free it, the whitelister takes ownership of the string } + else { + if (debug_syslog > 1) { + char msg[maxlen]; + snprintf(msg, sizeof(msg), "avoid whitelist reply from <%s> for outgoing auto-responder", loto); + my_syslog(&priv, msg); + } + if (loto) free((void*)loto);// or we free it here + } delete dwp; priv.delayer.pop_front(); }