summaryrefslogtreecommitdiff
path: root/src/modules/m_dnsbl.cpp
diff options
context:
space:
mode:
authorattilamolnar <attilamolnar@hush.com>2012-09-30 01:10:57 +0200
committerattilamolnar <attilamolnar@hush.com>2012-09-30 03:04:07 +0200
commit02859be56d43bcece02aab350e02bc95ed1bf446 (patch)
treebbb68a91e26f4502c22047ad2b26ed8918c5fbb1 /src/modules/m_dnsbl.cpp
parent83e90c4baa1215caf05295aec86a0a4d7bfff3f9 (diff)
Fix more undefined behavior caused by referencing the returned buffer by std::string::c_str() when the object is temporary
See 83c7cc45daf6fb1f8c36f15297a4657e45a34e88
Diffstat (limited to 'src/modules/m_dnsbl.cpp')
-rw-r--r--src/modules/m_dnsbl.cpp33
1 files changed, 21 insertions, 12 deletions
diff --git a/src/modules/m_dnsbl.cpp b/src/modules/m_dnsbl.cpp
index 645949006..52500dec8 100644
--- a/src/modules/m_dnsbl.cpp
+++ b/src/modules/m_dnsbl.cpp
@@ -142,8 +142,9 @@ class DNSBLResolver : public Resolver
"*", them->GetIPString());
if (ServerInstance->XLines->AddLine(kl,NULL))
{
- ServerInstance->SNO->WriteGlobalSno('x',"K:line added due to DNSBL match on *@%s to expire on %s: %s",
- them->GetIPString(), ServerInstance->TimeString(kl->expiry).c_str(), reason.c_str());
+ std::string timestr = ServerInstance->TimeString(kl->expiry);
+ ServerInstance->SNO->WriteGlobalSno('x',"K:line added due to DNSBL match on *@%s to expire on %s: %s",
+ them->GetIPString(), timestr.c_str(), reason.c_str());
ServerInstance->XLines->ApplyLines();
}
else
@@ -156,8 +157,9 @@ class DNSBLResolver : public Resolver
"*", them->GetIPString());
if (ServerInstance->XLines->AddLine(gl,NULL))
{
- ServerInstance->SNO->WriteGlobalSno('x',"G:line added due to DNSBL match on *@%s to expire on %s: %s",
- them->GetIPString(), ServerInstance->TimeString(gl->expiry).c_str(), reason.c_str());
+ std::string timestr = ServerInstance->TimeString(gl->expiry);
+ ServerInstance->SNO->WriteGlobalSno('x',"G:line added due to DNSBL match on *@%s to expire on %s: %s",
+ them->GetIPString(), timestr.c_str(), reason.c_str());
ServerInstance->XLines->ApplyLines();
}
else
@@ -170,8 +172,9 @@ class DNSBLResolver : public Resolver
them->GetIPString());
if (ServerInstance->XLines->AddLine(zl,NULL))
{
- ServerInstance->SNO->WriteGlobalSno('x',"Z:line added due to DNSBL match on *@%s to expire on %s: %s",
- them->GetIPString(), ServerInstance->TimeString(zl->expiry).c_str(), reason.c_str());
+ std::string timestr = ServerInstance->TimeString(zl->expiry);
+ ServerInstance->SNO->WriteGlobalSno('x',"Z:line added due to DNSBL match on *@%s to expire on %s: %s",
+ them->GetIPString(), timestr.c_str(), reason.c_str());
ServerInstance->XLines->ApplyLines();
}
else
@@ -307,29 +310,35 @@ class ModuleDNSBL : public Module
/* yeah, logic here is a little messy */
if ((e->bitmask <= 0) && (DNSBLConfEntry::A_BITMASK == e->type))
{
- ServerInstance->SNO->WriteGlobalSno('a', "DNSBL(%s): invalid bitmask",tag->getTagLocation().c_str());
+ std::string location = tag->getTagLocation();
+ ServerInstance->SNO->WriteGlobalSno('a', "DNSBL(%s): invalid bitmask", location.c_str());
}
else if (e->name.empty())
{
- ServerInstance->SNO->WriteGlobalSno('a', "DNSBL(%s): Invalid name",tag->getTagLocation().c_str());
+ std::string location = tag->getTagLocation();
+ ServerInstance->SNO->WriteGlobalSno('a', "DNSBL(%s): Invalid name", location.c_str());
}
else if (e->domain.empty())
{
- ServerInstance->SNO->WriteGlobalSno('a', "DNSBL(%s): Invalid domain",tag->getTagLocation().c_str());
+ std::string location = tag->getTagLocation();
+ ServerInstance->SNO->WriteGlobalSno('a', "DNSBL(%s): Invalid domain", location.c_str());
}
else if (e->banaction == DNSBLConfEntry::I_UNKNOWN)
{
- ServerInstance->SNO->WriteGlobalSno('a', "DNSBL(%s): Invalid banaction",tag->getTagLocation().c_str());
+ std::string location = tag->getTagLocation();
+ ServerInstance->SNO->WriteGlobalSno('a', "DNSBL(%s): Invalid banaction", location.c_str());
}
else if (e->duration <= 0)
{
- ServerInstance->SNO->WriteGlobalSno('a', "DNSBL(%s): Invalid duration",tag->getTagLocation().c_str());
+ std::string location = tag->getTagLocation();
+ ServerInstance->SNO->WriteGlobalSno('a', "DNSBL(%s): Invalid duration", location.c_str());
}
else
{
if (e->reason.empty())
{
- ServerInstance->SNO->WriteGlobalSno('a', "DNSBL(%s): empty reason, using defaults",tag->getTagLocation().c_str());
+ std::string location = tag->getTagLocation();
+ ServerInstance->SNO->WriteGlobalSno('a', "DNSBL(%s): empty reason, using defaults", location.c_str());
e->reason = "Your IP has been blacklisted.";
}