Mercurial > dnsbl
comparison src/dnsbl.cpp @ 284:896b9393d3f0 stable-6-0-39
Fix segfault caused by freeing unallocated memory
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Tue, 31 Dec 2013 10:44:15 -0800 |
parents | e276180647ab |
children | 9bd5388bf469 |
comparison
equal
deleted
inserted
replaced
283:7438f79afeb0 | 284:896b9393d3f0 |
---|---|
1174 priv.queueid = strdup(smfi_getsymval(ctx, (char*)"i")); | 1174 priv.queueid = strdup(smfi_getsymval(ctx, (char*)"i")); |
1175 priv.authenticated = smfi_getsymval(ctx, (char*)"{auth_authen}"); | 1175 priv.authenticated = smfi_getsymval(ctx, (char*)"{auth_authen}"); |
1176 priv.client_name = smfi_getsymval(ctx, (char*)"_"); | 1176 priv.client_name = smfi_getsymval(ctx, (char*)"_"); |
1177 if (!priv.helo) priv.helo = strdup("unknown"); | 1177 if (!priv.helo) priv.helo = strdup("unknown"); |
1178 if (priv.authenticated) priv.authenticated = strdup(priv.authenticated); | 1178 if (priv.authenticated) priv.authenticated = strdup(priv.authenticated); |
1179 { | |
1180 const char *uid = (priv.authenticated) ? priv.authenticated : priv.mailaddr; | |
1181 if (priv.authenticated || dc.default_context->is_unauthenticated_limited(priv.mailaddr)) { | |
1182 int hourly, daily; | |
1183 add_auth_address(uid, hourly, daily, priv.ip); | |
1184 int h_limit = dc.default_context->find_address_limit(uid); | |
1185 int d_limit = dc.default_context->get_daily_address_multiple() * h_limit; | |
1186 if (debug_syslog > 1) { | |
1187 char msg[maxlen]; | |
1188 snprintf(msg, sizeof(msg), "connect for %s (%d %d addresses, %d %d limits)", uid, hourly, daily, h_limit, d_limit); | |
1189 my_syslog(&priv, msg); | |
1190 } | |
1191 if ((hourly > h_limit) || (daily > d_limit)){ | |
1192 smfi_setreply(ctx, (char*)"550", (char*)"5.7.1", (char*)"unique connection ip address limit exceeded"); | |
1193 return SMFIS_REJECT; | |
1194 } | |
1195 } | |
1196 } | |
1197 if (priv.client_name) { | 1179 if (priv.client_name) { |
1198 priv.client_name = strdup(priv.client_name); | 1180 priv.client_name = strdup(priv.client_name); |
1199 const char *p = strstr(priv.client_name, " ["); | 1181 const char *p = strstr(priv.client_name, " ["); |
1200 if (p) { | 1182 if (p) { |
1201 uint pp = p - priv.client_name; | 1183 uint pp = p - priv.client_name; |
1218 if (spamc != spamc_empty) { | 1200 if (spamc != spamc_empty) { |
1219 priv.assassin = new SpamAssassin(&priv, priv.ip, priv.helo, priv.mailaddr, priv.queueid); | 1201 priv.assassin = new SpamAssassin(&priv, priv.ip, priv.helo, priv.mailaddr, priv.queueid); |
1220 } | 1202 } |
1221 if (dccifd_port) { | 1203 if (dccifd_port) { |
1222 priv.dccifd = new DccInterface(dccifd_port, &priv, priv.ip, priv.helo, priv.mailaddr); | 1204 priv.dccifd = new DccInterface(dccifd_port, &priv, priv.ip, priv.helo, priv.mailaddr); |
1205 } | |
1206 const char *uid = (priv.authenticated) ? priv.authenticated : priv.mailaddr; | |
1207 if (priv.authenticated || dc.default_context->is_unauthenticated_limited(priv.mailaddr)) { | |
1208 int hourly, daily; | |
1209 add_auth_address(uid, hourly, daily, priv.ip); | |
1210 int h_limit = dc.default_context->find_address_limit(uid); | |
1211 int d_limit = dc.default_context->get_daily_address_multiple() * h_limit; | |
1212 if (debug_syslog > 1) { | |
1213 char msg[maxlen]; | |
1214 snprintf(msg, sizeof(msg), "connect for %s (%d %d addresses, %d %d limits)", uid, hourly, daily, h_limit, d_limit); | |
1215 my_syslog(&priv, msg); | |
1216 } | |
1217 if ((hourly > h_limit) || (daily > d_limit)){ | |
1218 smfi_setreply(ctx, (char*)"550", (char*)"5.7.1", (char*)"unique connection ip address limit exceeded"); | |
1219 return SMFIS_REJECT; | |
1220 } | |
1223 } | 1221 } |
1224 return SMFIS_CONTINUE; | 1222 return SMFIS_CONTINUE; |
1225 } | 1223 } |
1226 | 1224 |
1227 sfsistat mlfi_envrcpt(SMFICTX *ctx, char **rcpt) | 1225 sfsistat mlfi_envrcpt(SMFICTX *ctx, char **rcpt) |