pkgsrc/chat/licq-core/patches/patch-ac
tonnerre 2b32a72a59 Fix multiple connection handling Denial of Service vulnerability in licq
(CVE-2008-1996). Before this, the application would crash if too many TCP
connections are opened.
2008-05-11 04:12:34 +00:00

36 lines
1.1 KiB
Text

$NetBSD: patch-ac,v 1.5 2008/05/11 04:12:34 tonnerre Exp $
--- src/icqd-threads.cpp.orig 2007-09-28 22:11:35.000000000 +0200
+++ src/icqd-threads.cpp
@@ -23,6 +23,7 @@
// Localization
#include "gettext.h"
+#define MAX_CONNECTS 256
#define DEBUG_THREADS(x)
//#define DEBUG_THREADS(x) gLog.Info(x)
@@ -780,8 +781,21 @@ void *MonitorSockets_tep(void *p)
TCPSocket *newSocket = new TCPSocket(0);
tcp->RecvConnection(*newSocket);
gSocketManager.DropSocket(tcp);
- gSocketManager.AddSocket(newSocket);
- gSocketManager.DropSocket(newSocket);
+
+ // Make sure we can handle another socket before accepting it
+ if (gSocketManager.Num() > MAX_CONNECTS)
+ {
+ // Too many sockets, drop this one
+ char remoteIp[32];
+ gLog.Warn(tr("%sToo many connected sockets, rejecting connection from %s.\n"),
+ L_WARNxSTR, newSocket->RemoteIpStr(remoteIp));
+ delete newSocket;
+ }
+ else
+ {
+ gSocketManager.AddSocket(newSocket);
+ gSocketManager.DropSocket(newSocket);
+ }
}
}