From 94824e4d2ba5b4f0f1aaf3810e1760b72cffa4bc Mon Sep 17 00:00:00 2001
From: zzz <zzz@mail.i2p>
Date: Sat, 30 May 2015 14:02:38 +0000
Subject: [PATCH] I2CP: Prevent sending data message before handshake with
 router is complete

---
 core/java/src/net/i2p/client/I2PSessionImpl.java      | 2 ++
 core/java/src/net/i2p/client/I2PSessionImpl2.java     | 2 ++
 core/java/src/net/i2p/client/I2PSessionMuxedImpl.java | 2 ++
 3 files changed, 6 insertions(+)

diff --git a/core/java/src/net/i2p/client/I2PSessionImpl.java b/core/java/src/net/i2p/client/I2PSessionImpl.java
index 7527dd8862..a6652556ce 100644
--- a/core/java/src/net/i2p/client/I2PSessionImpl.java
+++ b/core/java/src/net/i2p/client/I2PSessionImpl.java
@@ -619,6 +619,8 @@ public abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2
                 throw new I2PSessionException("Already closed");
             if (_state == State.INIT)
                 throw new I2PSessionException("Not open, must call connect() first");
+            if (_state == State.OPENING) // not before GOTDATE
+                throw new I2PSessionException("Session not open yet");
         }
         _producer.reportAbuse(this, msgId, severity);
     }
diff --git a/core/java/src/net/i2p/client/I2PSessionImpl2.java b/core/java/src/net/i2p/client/I2PSessionImpl2.java
index 5cd2b930c4..d58f5b5f14 100644
--- a/core/java/src/net/i2p/client/I2PSessionImpl2.java
+++ b/core/java/src/net/i2p/client/I2PSessionImpl2.java
@@ -252,6 +252,8 @@ class I2PSessionImpl2 extends I2PSessionImpl {
                 throw new I2PSessionException("Already closed");
             if (_state == State.INIT)
                 throw new I2PSessionException("Not open, must call connect() first");
+            if (_state == State.OPENING || _state == State.GOTDATE) // not before GOTDATE or session
+                throw new I2PSessionException("Session not open yet");
         }
         updateActivity();
 
diff --git a/core/java/src/net/i2p/client/I2PSessionMuxedImpl.java b/core/java/src/net/i2p/client/I2PSessionMuxedImpl.java
index 0185496aa3..94eb6ae451 100644
--- a/core/java/src/net/i2p/client/I2PSessionMuxedImpl.java
+++ b/core/java/src/net/i2p/client/I2PSessionMuxedImpl.java
@@ -261,6 +261,8 @@ class I2PSessionMuxedImpl extends I2PSessionImpl2 {
                 throw new I2PSessionException("Already closed");
             if (_state == State.INIT)
                 throw new I2PSessionException("Not open, must call connect() first");
+            if (_state == State.OPENING || _state == State.GOTDATE) // not before GOTDATE or session
+                throw new I2PSessionException("Session not open yet");
         }
         updateActivity();
 
-- 
GitLab