summaryrefslogtreecommitdiff
path: root/src/modules/m_ident.cpp
diff options
context:
space:
mode:
authorattilamolnar <attilamolnar@hush.com>2012-12-15 19:41:58 +0100
committerattilamolnar <attilamolnar@hush.com>2012-12-15 19:47:47 +0100
commitab65f7902f9e4aeda68e9797f1904f02d1f9fc35 (patch)
treeb9b4b8d9cd462af1ed72411fd04ea2ca70c9100a /src/modules/m_ident.cpp
parente3e3a35899931d98e76023464f9b077b09ba828d (diff)
m_ident Reject invalid and error replies
Diffstat (limited to 'src/modules/m_ident.cpp')
-rw-r--r--src/modules/m_ident.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp
index 4d66a739e..f1c3b81fd 100644
--- a/src/modules/m_ident.cpp
+++ b/src/modules/m_ident.cpp
@@ -235,10 +235,16 @@ class IdentRequestSocket : public EventHandler
*/
ibuf[recvresult] = '\0';
std::string buf(ibuf);
- std::string::size_type lastcolon = buf.rfind(':');
- if (lastcolon == std::string::npos)
+
+ /* <2 colons: invalid
+ * 2 colons: reply is an error
+ * >3 colons: there is a colon in the ident
+ */
+ if (std::count(buf.begin(), buf.end(), ':') != 3)
return;
+ std::string::size_type lastcolon = buf.rfind(':');
+
/* Truncate the ident at any characters we don't like, skip leading spaces */
for (std::string::const_iterator i = buf.begin()+lastcolon+1; i != buf.end(); ++i)
{