I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 10efecaa authored by zzz's avatar zzz
Browse files

* IRC Server tunnel: Reject bad protocols immediately

parent 689b045a
No related branches found
No related tags found
No related merge requests found
......@@ -72,6 +72,11 @@ public class I2PTunnelIRCServer extends I2PTunnelServer implements Runnable {
"\r\n")
.getBytes();
private static final String[] BAD_PROTOCOLS = {
"GET ", "HEAD ", "POST ", "GNUTELLA CONNECT", "\023BitTorrent protocol"
};
/**
* @throws IllegalArgumentException if the I2PTunnel does not contain
* valid config to contact the router
......@@ -193,6 +198,12 @@ public class I2PTunnelIRCServer extends I2PTunnelServer implements Runnable {
String s = DataHelper.readLine(in);
if (s == null)
throw new IOException("EOF reached before the end of the headers [" + buf.toString() + "]");
if (lineCount == 0) {
for (int i = 0; i < BAD_PROTOCOLS.length; i++) {
if (s.startsWith(BAD_PROTOCOLS[i]))
throw new IOException("Bad protocol " + BAD_PROTOCOLS[i]);
}
}
if (++lineCount > 10)
throw new IOException("Too many lines before USER or SERVER, giving up");
if (System.currentTimeMillis() > expire)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment