Limit chat history to 250 entries to avoid DoS attack with its use
authorunc0rr
Thu, 27 Nov 2008 15:01:12 +0000
changeset 1516 bb9fa5809c49
parent 1515 0cf2edcfdd8f
child 1517 27caa8c6e73a
Limit chat history to 250 entries to avoid DoS attack with its use
QTfrontend/chatwidget.cpp
--- a/QTfrontend/chatwidget.cpp	Thu Nov 27 14:55:49 2008 +0000
+++ b/QTfrontend/chatwidget.cpp	Thu Nov 27 15:01:12 2008 +0000
@@ -63,10 +63,14 @@
 
 void HWChatWidget::onChatString(const QString& str)
 {
-  QListWidget* w = chatText;
-  w->addItem(str);
-  w->scrollToBottom();
-  w->setSelectionMode(QAbstractItemView::NoSelection);
+	QListWidget* w = chatText;
+	
+	if (w->count() > 250)
+		delete w->item(0);
+
+	w->addItem(str);
+	w->scrollToBottom();
+	w->setSelectionMode(QAbstractItemView::NoSelection);
 }
 
 void HWChatWidget::nickAdded(const QString& nick)