~ubuntu-branches/ubuntu/jaunty/quassel/jaunty-backports

« back to all changes in this revision

Viewing changes to debian/patches/quassel_16_ctcp_level_and_low_level_quoting.patch

  • Committer: Bazaar Package Importer
  • Author(s): Harald Sitter
  • Date: 2008-10-25 18:30:49 UTC
  • Revision ID: james.westby@ubuntu.com-20081025183049-hb1qd45hvboo1zxv
Tags: 0.3.0-0ubuntu8
* Added patch from upstream:
  + quassel_16_ctcp_level_and_low_level_quoting.patch
    Implementing ctcp level quoting and ctcp low level quoting.
    This fixes a crucial security issue. (LP: #289182)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Index: quassel-0.3.0/src/core/ctcphandler.cpp
 
2
===================================================================
 
3
--- quassel-0.3.0.orig/src/core/ctcphandler.cpp 2008-08-27 15:48:56.000000000 +0200
 
4
+++ quassel-0.3.0/src/core/ctcphandler.cpp      2008-10-25 18:12:01.000000000 +0200
 
5
@@ -40,7 +40,17 @@
 
6
   ctcpXDelimDequoteHash[XQUOTE + QByteArray("a")] = XDELIM;
 
7
 }
 
8
 
 
9
-QByteArray CtcpHandler::dequote(const QByteArray &message) {
 
10
+QByteArray CtcpHandler::lowLevelQuote(const QByteArray &message) {
 
11
+  QByteArray quotedMessage = message;
 
12
+  QHash<QByteArray, QByteArray>::const_iterator quoteIter = ctcpMDequoteHash.constBegin();
 
13
+  while(quoteIter != ctcpMDequoteHash.constEnd()) {
 
14
+    quotedMessage.replace(quoteIter.value(), quoteIter.key());
 
15
+    quoteIter++;
 
16
+  }
 
17
+  return quotedMessage;
 
18
+}
 
19
+
 
20
+QByteArray CtcpHandler::lowLevelDequote(const QByteArray &message) {
 
21
   QByteArray dequotedMessage;
 
22
   QByteArray messagepart;
 
23
   QHash<QByteArray, QByteArray>::iterator ctcpquote;
 
24
@@ -62,6 +72,15 @@
 
25
   return dequotedMessage;
 
26
 }
 
27
 
 
28
+QByteArray CtcpHandler::xdelimQuote(const QByteArray &message) {
 
29
+  QByteArray quotedMessage = message;
 
30
+  QHash<QByteArray, QByteArray>::const_iterator quoteIter = ctcpXDelimDequoteHash.constBegin();
 
31
+  while(quoteIter != ctcpXDelimDequoteHash.constEnd()) {
 
32
+    quotedMessage.replace(quoteIter.value(), quoteIter.key());
 
33
+    quoteIter++;
 
34
+  }
 
35
+  return quotedMessage;
 
36
+}
 
37
 
 
38
 QByteArray CtcpHandler::xdelimDequote(const QByteArray &message) {
 
39
   QByteArray dequotedMessage;
 
40
@@ -88,7 +107,7 @@
 
41
   QByteArray ctcp;
 
42
   
 
43
   //lowlevel message dequote
 
44
-  QByteArray dequotedMessage = dequote(message);
 
45
+  QByteArray dequotedMessage = lowLevelDequote(message);
 
46
 
 
47
   CtcpType ctcptype = messageType == Message::Notice
 
48
     ? CtcpReply
 
49
@@ -135,19 +154,18 @@
 
50
 }
 
51
 
 
52
 QByteArray CtcpHandler::pack(const QByteArray &ctcpTag, const QByteArray &message) {
 
53
-  return XDELIM + ctcpTag + ' ' + message + XDELIM;
 
54
+  return XDELIM + ctcpTag + ' ' + xdelimQuote(message) + XDELIM;
 
55
 }
 
56
 
 
57
-// TODO handle encodings correctly!
 
58
 void CtcpHandler::query(const QString &bufname, const QString &ctcpTag, const QString &message) {
 
59
   QList<QByteArray> params;
 
60
-  params << serverEncode(bufname) << pack(serverEncode(ctcpTag), userEncode(bufname, message));
 
61
+  params << serverEncode(bufname) << lowLevelQuote(pack(serverEncode(ctcpTag), userEncode(bufname, message)));
 
62
   emit putCmd("PRIVMSG", params);
 
63
 }
 
64
 
 
65
 void CtcpHandler::reply(const QString &bufname, const QString &ctcpTag, const QString &message) {
 
66
   QList<QByteArray> params;
 
67
-  params << serverEncode(bufname) << pack(serverEncode(ctcpTag), userEncode(bufname, message));
 
68
+  params << serverEncode(bufname) << lowLevelQuote(pack(serverEncode(ctcpTag), userEncode(bufname, message)));
 
69
   emit putCmd("NOTICE", params);
 
70
 }
 
71
 
 
72
Index: quassel-0.3.0/src/core/ctcphandler.h
 
73
===================================================================
 
74
--- quassel-0.3.0.orig/src/core/ctcphandler.h   2008-08-27 15:48:56.000000000 +0200
 
75
+++ quassel-0.3.0/src/core/ctcphandler.h        2008-10-25 18:12:01.000000000 +0200
 
76
@@ -36,7 +36,9 @@
 
77
 
 
78
   void parse(Message::Type, const QString &prefix, const QString &target, const QByteArray &message);
 
79
 
 
80
-  QByteArray dequote(const QByteArray &);
 
81
+  QByteArray lowLevelQuote(const QByteArray &);
 
82
+  QByteArray lowLevelDequote(const QByteArray &);
 
83
+  QByteArray xdelimQuote(const QByteArray &);
 
84
   QByteArray xdelimDequote(const QByteArray &);
 
85
 
 
86
   QByteArray pack(const QByteArray &ctcpTag, const QByteArray &message);