From f6cff78528c3f864fc933a452903c7527815f075 Mon Sep 17 00:00:00 2001 From: zzz <zzz@mail.i2p> Date: Wed, 30 Nov 2011 23:16:29 +0000 Subject: [PATCH] * IRC Server: Fix IOOBE (ticket #559) --- .../net/i2p/i2ptunnel/I2PTunnelIRCServer.java | 8 +++----- .../src/net/i2p/i2ptunnel/irc/IRCFilter.java | 19 +++++++++---------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelIRCServer.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelIRCServer.java index fc78131b81..da063b0d0c 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelIRCServer.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelIRCServer.java @@ -198,15 +198,13 @@ public class I2PTunnelIRCServer extends I2PTunnelServer implements Runnable { String field[]=s.split(" ",5); String command; int idx=0; - - if(field[0].charAt(0)==':') - idx++; try { + if (field[0].charAt(0) == ':') + idx++; command = field[idx++].toUpperCase(Locale.US); } catch (IndexOutOfBoundsException ioobe) { - // wtf, server sent borked command? - throw new IOException("Dropping defective message: index out of bounds while extracting command."); + throw new IOException("Dropping defective message: [" + s + ']'); } if ("USER".equals(command)) { diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/irc/IRCFilter.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/irc/IRCFilter.java index 73f6bb887a..fc7c8ec6d8 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/irc/IRCFilter.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/irc/IRCFilter.java @@ -55,12 +55,13 @@ abstract class IRCFilter { "CAP" }; - if(field[0].charAt(0)==':') - idx++; - try { command = field[idx++].toUpperCase(Locale.US); } - catch (IndexOutOfBoundsException ioobe) // wtf, server sent borked command? - { + try { + if (field[0].charAt(0) == ':') + idx++; + command = field[idx++].toUpperCase(Locale.US); + } catch (IndexOutOfBoundsException ioobe) { + // wtf, server sent borked command? //_log.warn("Dropping defective message: index out of bounds while extracting command."); return null; } @@ -151,6 +152,7 @@ abstract class IRCFilter { // Commands that regular users might use "ADMIN", "AWAY", // should be harmless + "CAP", // http://tools.ietf.org/html/draft-mitchell-irc-capabilities-01 "CYCLE", "DCCALLOW", "HELPME", "HELPOP", // helpop is what unrealircd uses by default @@ -226,12 +228,9 @@ abstract class IRCFilter { "TEMPSHUN", "UNDCCDENY", "WALLOPS", - "ZLINE", - // http://tools.ietf.org/html/draft-mitchell-irc-capabilities-01 - "CAP" + "ZLINE" }; - _allowedOutbound = new HashSet(64); - _allowedOutbound.addAll(Arrays.asList(allowedCommands)); + _allowedOutbound = new HashSet(Arrays.asList(allowedCommands)); } /************************************************************************* -- GitLab