fwiw don't allow stanza count to go over MAX_INT

This commit is contained in:
Daniel Gultsch 2015-05-06 04:29:45 +02:00
parent b7c672e10e
commit db726a59b8
1 changed files with 9 additions and 0 deletions

View File

@ -437,6 +437,10 @@ public class XmppConnection implements Runnable {
throw new IOException("interrupted mid tag"); throw new IOException("interrupted mid tag");
} }
} }
if (stanzasReceived == Integer.MAX_VALUE) {
resetStreamId();
throw new IOException("time to restart the session. cant handle >2 billion pcks");
}
++stanzasReceived; ++stanzasReceived;
lastPacketReceived = SystemClock.elapsedRealtime(); lastPacketReceived = SystemClock.elapsedRealtime();
return element; return element;
@ -901,6 +905,11 @@ public class XmppConnection implements Runnable {
} }
private synchronized void sendPacket(final AbstractStanza packet) { private synchronized void sendPacket(final AbstractStanza packet) {
if (stanzasSent == Integer.MAX_VALUE) {
resetStreamId();
disconnect(true);
return;
}
final String name = packet.getName(); final String name = packet.getName();
if (name.equals("iq") || name.equals("message") || name.equals("presence")) { if (name.equals("iq") || name.equals("message") || name.equals("presence")) {
++stanzasSent; ++stanzasSent;