File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,9 @@ QT_END_NAMESPACE
52
52
53
53
class CWallet ;
54
54
55
+ // BIP70 max payment request size in bytes (DoS protection)
56
+ extern const qint64 BIP70_MAX_PAYMENTREQUEST_SIZE;
57
+
55
58
class PaymentServer : public QObject
56
59
{
57
60
Q_OBJECT
@@ -85,6 +88,9 @@ class PaymentServer : public QObject
85
88
// OptionsModel is used for getting proxy settings and display unit
86
89
void setOptionsModel (OptionsModel *optionsModel);
87
90
91
+ // This is now public, because we use it in paymentservertests.cpp
92
+ static bool readPaymentRequestFromFile (const QString& filename, PaymentRequestPlus& request);
93
+
88
94
signals:
89
95
// Fired when a valid payment request is received
90
96
void receivedPaymentRequest (SendCoinsRecipient);
@@ -118,7 +124,6 @@ private slots:
118
124
bool eventFilter (QObject *object, QEvent *event);
119
125
120
126
private:
121
- static bool readPaymentRequestFromFile (const QString& filename, PaymentRequestPlus& request);
122
127
bool processPaymentRequest (PaymentRequestPlus& request, SendCoinsRecipient& recipient);
123
128
void fetchRequest (const QUrl& url);
124
129
Original file line number Diff line number Diff line change 7
7
#include " optionsmodel.h"
8
8
#include " paymentrequestdata.h"
9
9
10
+ #include " random.h"
10
11
#include " util.h"
11
12
#include " utilstrencodings.h"
12
13
@@ -108,6 +109,17 @@ void PaymentServerTests::paymentServerTests()
108
109
r.paymentRequest .getMerchant (caStore, merchant);
109
110
QCOMPARE (merchant, QString (" " ));
110
111
112
+ // Just get some random data big enough to trigger BIP70 DoS protection
113
+ unsigned char randData[BIP70_MAX_PAYMENTREQUEST_SIZE + 1 ];
114
+ GetRandBytes (randData, sizeof (randData));
115
+ // Write data to a temp file:
116
+ QTemporaryFile tempFile;
117
+ tempFile.open ();
118
+ tempFile.write ((const char *)randData, sizeof (randData));
119
+ tempFile.close ();
120
+ // Trigger BIP70 DoS protection
121
+ QCOMPARE (PaymentServer::readPaymentRequestFromFile (tempFile.fileName (), r.paymentRequest ), false );
122
+
111
123
delete server;
112
124
}
113
125
You can’t perform that action at this time.
0 commit comments