summaryrefslogtreecommitdiff
path: root/community/murmur/0003-fix-long-username-query.patch
blob: 2fc52f70c41f91c988253eebc4d03f6d65bf9f95 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
commit 6b33dda344f89e5a039b7d79eb43925040654242
Author: Benjamin Jemlich <pcgod@users.sourceforge.net>
Date:   Tue Jun 29 14:49:14 2010 +0200

    Don't crash on long usernames

diff --git a/src/murmur/Messages.cpp b/src/murmur/Messages.cpp
index f12867a..de307ea 100644
--- a/src/murmur/Messages.cpp
+++ b/src/murmur/Messages.cpp
@@ -1231,6 +1231,9 @@ void Server::msgQueryUsers(ServerUser *uSource, MumbleProto::QueryUsers &msg) {
 
 	for (int i=0;i<msg.names_size();++i) {
 		QString name = u8(msg.names(i));
+		if (!validateUserName(name)) {
+			continue;
+		}
 		int id = getUserID(name);
 		if (id >= 0) {
 			name = getUserName(id);
diff --git a/src/murmur/ServerDB.cpp b/src/murmur/ServerDB.cpp
index 11b6906..7e15def 100644
--- a/src/murmur/ServerDB.cpp
+++ b/src/murmur/ServerDB.cpp
@@ -810,7 +810,7 @@ int Server::authenticate(QString &name, const QString &pw, const QStringList &em
 	TransactionHolder th;
 	QSqlQuery &query = *th.qsqQuery;
 
-	SQLPREP("SELECT `user_id`,`name`,`pw` FROM `%1users` WHERE `server_id` = ? AND `name` like ?");
+	SQLPREP("SELECT `user_id`,`name`,`pw` FROM `%1users` WHERE `server_id` = ? AND LOWER(`name`) = LOWER(?)");
 	query.addBindValue(iServerNum);
 	query.addBindValue(name);
 	SQLEXEC();
@@ -1051,7 +1051,7 @@ int Server::getUserID(const QString &name) {
 	TransactionHolder th;
 
 	QSqlQuery &query = *th.qsqQuery;
-	SQLPREP("SELECT `user_id` FROM `%1users` WHERE `server_id` = ? AND `name` like ?");
+	SQLPREP("SELECT `user_id` FROM `%1users` WHERE `server_id` = ? AND LOWER(`name`) = LOWER(?)");
 	query.addBindValue(iServerNum);
 	query.addBindValue(name);
 	SQLEXEC();