Mercurial > dnsbl
comparison 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 |
comparison
equal
deleted
inserted
replaced
230:ad38575e98ca | 231:4d6bd04d93fa |
---|---|
295 reset(true); | 295 reset(true); |
296 } | 296 } |
297 | 297 |
298 void mlfiPriv::reset(bool final) { | 298 void mlfiPriv::reset(bool final) { |
299 while (!delayer.empty()) { | 299 while (!delayer.empty()) { |
300 DELAYWHITEP dwp = delayer.front(); | 300 DELAYWHITEP dwp = delayer.front(); |
301 const char *loto = dwp->get_loto(); | |
302 if (loto) free((void*)loto); | |
301 delete dwp; | 303 delete dwp; |
302 delayer.pop_front(); | 304 delayer.pop_front(); |
303 } | 305 } |
304 if (mailaddr) free((void*)mailaddr); | 306 if (mailaddr) free((void*)mailaddr); |
305 if (queueid) free((void*)queueid); | 307 if (queueid) free((void*)queueid); |
1136 const char *p = strchr(loto, '@'); | 1138 const char *p = strchr(loto, '@'); |
1137 int len = (p) ? p-loto : max_local_size; | 1139 int len = (p) ? p-loto : max_local_size; |
1138 if (len >= max_local_size) w = NULL; // too big, pretend we don't have a whitelister | 1140 if (len >= max_local_size) w = NULL; // too big, pretend we don't have a whitelister |
1139 // record it if we have a whitelister | 1141 // record it if we have a whitelister |
1140 if (w) { | 1142 if (w) { |
1141 DELAYWHITEP dwp = new DELAYWHITE(loto, w, &con2); | 1143 DELAYWHITEP dwp = new DELAYWHITE(loto, w, &con2); // dwp takes ownership of the string |
1142 priv.delayer.push_back(dwp); | 1144 priv.delayer.push_back(dwp); |
1143 } | 1145 } |
1144 else { | 1146 else { |
1145 free((void*)loto); | 1147 free((void*)loto); // or we free it here |
1146 } | 1148 } |
1147 | 1149 |
1148 // accept the recipient | 1150 // accept the recipient |
1149 if (!con.get_content_filtering()) st = white; | 1151 if (!con.get_content_filtering()) st = white; |
1150 | 1152 |
1174 } | 1176 } |
1175 | 1177 |
1176 sfsistat mlfi_header(SMFICTX* ctx, char* headerf, char* headerv) | 1178 sfsistat mlfi_header(SMFICTX* ctx, char* headerf, char* headerv) |
1177 { | 1179 { |
1178 mlfiPriv &priv = *MLFIPRIV; | 1180 mlfiPriv &priv = *MLFIPRIV; |
1179 // detect precedence:bulk for avoiding autowhitelisting | 1181 // headers that avoid autowhitelisting |
1180 if (((strcasecmp(headerf, "precedence") == 0) && (strcasecmp(headerv, "bulk") == 0)) || | 1182 if (((strcasecmp(headerf, "precedence") == 0) && (strcasecmp(headerv, "bulk") == 0)) || |
1181 ((strcasecmp(headerf, "content-type") == 0) && (strncasecmp(headerv, "multipart/report", 16) == 0))) { | 1183 ((strcasecmp(headerf, "content-type") == 0) && (strncasecmp(headerv, "multipart/report", 16) == 0))) { |
1182 priv.allow_autowhitelisting = false; | 1184 priv.allow_autowhitelisting = false; |
1183 } | 1185 } |
1184 | 1186 |
1193 sfsistat mlfi_eoh(SMFICTX* ctx) | 1195 sfsistat mlfi_eoh(SMFICTX* ctx) |
1194 { | 1196 { |
1195 mlfiPriv &priv = *MLFIPRIV; | 1197 mlfiPriv &priv = *MLFIPRIV; |
1196 // delayed autowhitelisting | 1198 // delayed autowhitelisting |
1197 while (!priv.delayer.empty()) { | 1199 while (!priv.delayer.empty()) { |
1198 DELAYWHITEP dwp = priv.delayer.front(); | 1200 DELAYWHITEP dwp = priv.delayer.front(); |
1201 const char *loto = dwp->get_loto(); | |
1199 if (priv.allow_autowhitelisting) { | 1202 if (priv.allow_autowhitelisting) { |
1200 const char *loto = dwp->get_loto(); | |
1201 WHITELISTERP w = dwp->get_w(); | 1203 WHITELISTERP w = dwp->get_w(); |
1202 CONTEXTP con2 = dwp->get_con(); | 1204 CONTEXTP con2 = dwp->get_con(); |
1203 if (debug_syslog > 1) { | 1205 if (debug_syslog > 1) { |
1204 char buf[maxlen]; | 1206 char buf[maxlen]; |
1205 char msg[maxlen]; | 1207 char msg[maxlen]; |
1206 snprintf(msg, sizeof(msg), "whitelist reply from <%s> in context %s", loto, con2->get_full_name(buf,maxlen)); | 1208 snprintf(msg, sizeof(msg), "whitelist reply from <%s> in context %s", loto, con2->get_full_name(buf,maxlen)); |
1207 my_syslog(&priv, msg); | 1209 my_syslog(&priv, msg); |
1208 } | 1210 } |
1209 w->sent(loto); // don't free it, the whitelister takes ownership of the string | 1211 w->sent(loto); // don't free it, the whitelister takes ownership of the string |
1212 } | |
1213 else { | |
1214 if (debug_syslog > 1) { | |
1215 char msg[maxlen]; | |
1216 snprintf(msg, sizeof(msg), "avoid whitelist reply from <%s> for outgoing auto-responder", loto); | |
1217 my_syslog(&priv, msg); | |
1218 } | |
1219 if (loto) free((void*)loto);// or we free it here | |
1210 } | 1220 } |
1211 delete dwp; | 1221 delete dwp; |
1212 priv.delayer.pop_front(); | 1222 priv.delayer.pop_front(); |
1213 } | 1223 } |
1214 // content filtering | 1224 // content filtering |