Mercurial > dnsbl
diff src/context.cpp @ 173:83fe0be032c1 stable-6-0-9
fix leak, update timestamps when receiving auto-whitelisted sender
author | carl |
---|---|
date | Thu, 06 Sep 2007 09:50:05 -0700 |
parents | bd33eaccfed8 |
children | da0c41b9f672 |
line wrap: on
line diff
--- a/src/context.cpp Thu Aug 30 18:50:00 2007 -0700 +++ b/src/context.cpp Thu Sep 06 09:50:05 2007 -0700 @@ -69,7 +69,7 @@ pthread_mutex_t verifier_mutex; // protect the verifier map verify_map verifiers; -pthread_mutex_t whitelister_mutex; // protect the +pthread_mutex_t whitelister_mutex; // protect the whitelisters map whitelister_map whitelisters; string_set all_strings; // owns all the strings, only modified by the config loader thread @@ -447,12 +447,13 @@ time_t when = atoi(p+1); if ((when == 0) || (when > now)) when = now; autowhite_sent::iterator i = rcpts.find(who); - if (i != rcpts.end()) { - time_t wh = (*i).second; - if (when > wh) rcpts[who] = when; + if (i == rcpts.end()) { + rcpts[who] = when; } else { - rcpts[who] = when; + time_t wh = (*i).second; + if (when > wh) (*i).second = when; + free(who); } } } @@ -512,7 +513,14 @@ // we take ownership of the string pthread_mutex_lock(&mutex); need = true; + autowhite_sent::iterator i = rcpts.find(to); + if (i == rcpts.end()) { rcpts[to] = time(NULL); + } + else { + (*i).second = time(NULL); + free(to); + } pthread_mutex_unlock(&mutex); } @@ -784,8 +792,20 @@ } -char *CONTEXT::find_from(char *from) { - if (whitelister && whitelister->is_white(from)) return token_white; +char *CONTEXT::find_from(char *from, bool update_white) { + if (whitelister && whitelister->is_white(from)) { + if (update_white) { + // update senders timestamp to extend the whitelisting period + if (debug_syslog > 1) { + char buf[maxlen]; + char msg[maxlen]; + snprintf(msg, sizeof(msg), "extend whitelist reply from <%s> in context %s", from, get_full_name(buf,maxlen)); + my_syslog(msg); + } + whitelister->sent(strdup(from)); + } + return token_white; + } char *rc = env_from_default; string_map::iterator i = env_from.find(from); if (i != env_from.end()) rc = (*i).second; // found user@domain key