From 674df787418f4a9d0c5982ace95801715a41f3f0 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Tue, 21 Oct 2014 21:55:47 +0200 Subject: [PATCH] Fix parsing exception causing infinite loop Fixes SMACK-613 --- .../org/jivesoftware/smack/tcp/PacketReader.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/PacketReader.java b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/PacketReader.java index b5bf1f192..398c274da 100644 --- a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/PacketReader.java +++ b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/PacketReader.java @@ -160,6 +160,10 @@ class PacketReader { if (callback != null) { callback.handleUnparsablePacket(message); } + // The parser is now at the end tag of the unparsable stanza. We need to advance to the next + // start tag in order to avoid an exception which would again lead to the execution of the + // catch block becoming effectively an endless loop. + eventType = parser.next(); continue; } connection.processPacket(packet); @@ -174,6 +178,10 @@ class PacketReader { if (callback != null) { callback.handleUnparsablePacket(message); } + // The parser is now at the end tag of the unparsable stanza. We need to advance to the next + // start tag in order to avoid an exception which would again lead to the execution of the + // catch block becoming effectively an endless loop. + eventType = parser.next(); continue; } connection.processPacket(iq); @@ -188,6 +196,10 @@ class PacketReader { if (callback != null) { callback.handleUnparsablePacket(message); } + // The parser is now at the end tag of the unparsable stanza. We need to advance to the next + // start tag in order to avoid an exception which would again lead to the execution of the + // catch block becoming effectively an endless loop. + eventType = parser.next(); continue; } connection.processPacket(presence);