aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/extra/m_sqloper.cpp
diff options
context:
space:
mode:
authorGravatar brain2006-05-30 20:43:30 +0000
committerGravatar brain2006-05-30 20:43:30 +0000
commit6f6cf3fee9b04581d14d92729b0a81c4d29ef61c (patch)
treefa5375533e2d90ac4b3be01dc571b8cb9aa645a5 /src/modules/extra/m_sqloper.cpp
parentBack to 1.0.5+SVN again (diff)
Apply mirq's optimization patches
git-svn-id: http://svn.inspircd.org/repository/branches/1_0_stable@3978 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/extra/m_sqloper.cpp')
-rw-r--r--src/modules/extra/m_sqloper.cpp32
1 files changed, 3 insertions, 29 deletions
diff --git a/src/modules/extra/m_sqloper.cpp b/src/modules/extra/m_sqloper.cpp
index a5b79dc54..a1eff16ce 100644
--- a/src/modules/extra/m_sqloper.cpp
+++ b/src/modules/extra/m_sqloper.cpp
@@ -91,7 +91,7 @@ class ModuleSQLOper : public Module
return 0;
}
- bool LookupOper(std::string username, std::string password, userrec* user)
+ bool LookupOper(const std::string &s_username, const std::string &s_password, userrec* user)
{
bool found = false;
@@ -100,34 +100,8 @@ class ModuleSQLOper : public Module
return false;
// sanitize the password (we dont want any mysql insertion exploits!)
- std::string temp = "";
- for (unsigned int q = 0; q < password.length(); q++)
- {
- if (password[q] == '\'')
- {
- temp = temp + "\'";
- }
- else if (password[q] == '"')
- {
- temp = temp + "\\\"";
- }
- else temp = temp + password[q];
- }
- password = temp;
- temp = "";
- for (unsigned int v = 0; v < username.length(); v++)
- {
- if (username[v] == '\'')
- {
- temp = temp + "\'";
- }
- if (username[v] == '"')
- {
- temp = temp + "\\\"";
- }
- else temp = temp + username[v];
- }
- username = temp;
+ std::string username = SQLQuery::Sanitise(s_username);
+ std::string password = SQLQuery::Sanitise(s_password);
// Create a request containing the SQL query and send it to m_sql.so
SQLRequest* query = new SQLRequest(SQL_RESULT,dbid,"SELECT username,password,hostname,type FROM ircd_opers WHERE username='"+username+"' AND password=md5('"+password+"')");