Author: baufo
Date: Sun Mar 23 21:16:08 2008
New Revision: 25032
URL: http://svn.gna.org/viewcvs/wesnoth?rev=25032&view=rev
Log:
Security fix: escape all user entered query data.
Modified:
branches/mp_registration/src/server/user_handler.cpp
Modified: branches/mp_registration/src/server/user_handler.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/branches/mp_registration/src/server/user_handler.cpp?rev=25032&r1=25031&r2=25032&view=diff
==============================================================================
--- branches/mp_registration/src/server/user_handler.cpp (original)
+++ branches/mp_registration/src/server/user_handler.cpp Sun Mar 23 21:16:08
2008
@@ -228,8 +228,11 @@
std::string now = lexical_cast_default<std::string>(time(NULL));
- sql_query("insert into users
(name,password,email,realname,registration_date,last_login) values ('" +
- name + "','" + password + "','" + mail + "','','" + now + "','" +
now + "')");
+ sql_query(std::string(sqlite3_mprintf(
+ "insert into users
(name,password,email,realname,registration_date,last_login) "
+ "values ('%q','%q','%q','','%q','%q')",
+ name.c_str(), password.c_str(), mail.c_str(), now.c_str(),
now.c_str()))
+ );
users_.insert(std::pair<std::string,std::string*>(name,NULL));
users_[name] = new std::string[uh::MAX_VALUE];
@@ -289,7 +292,10 @@
throw error("Could not remove user. No user with the name '" + name +
"' exists.");
}
- sql_query("delete from users where name='" + name + "'");
+ sql_query(std::string(sqlite3_mprintf(
+ "delete from users where name='%q'",
+ name.c_str()))
+ );
users_.erase(users_.find(name));
@@ -315,7 +321,10 @@
"'. No user with the name with this name exists.");
}
- sql_query("update users set " + attribute + "='" + value + "' where
name='" + name + "'");
+ sql_query(std::string(sqlite3_mprintf(
+ "update users set %q='%q' where name='%q'",
+ attribute.c_str(), value.c_str(), name.c_str()))
+ );
std::string* u = users_[name];
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits