From 154c8bfb7fec81f81f13141fd7f27cd3706e4b8b Mon Sep 17 00:00:00 2001 From: T H Panton Date: Tue, 13 Oct 2020 11:03:52 +0100 Subject: [PATCH] Don't write on a closed channel Update to cope with junit cve --- pom.xml | 4 ++-- .../com/ipseorama/slice/SingleThreadNioIceEngine.java | 10 +++++++--- .../slice/stun/IceStunBindingTransaction.java | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index e3f6410..4d28fbf 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.ipseorama slice - 1.0.92-local + 1.1.0 jar @@ -27,7 +27,7 @@ junit junit - 4.12 + 4.13.1 test diff --git a/src/main/java/com/ipseorama/slice/SingleThreadNioIceEngine.java b/src/main/java/com/ipseorama/slice/SingleThreadNioIceEngine.java index 646e2eb..f07c4ad 100644 --- a/src/main/java/com/ipseorama/slice/SingleThreadNioIceEngine.java +++ b/src/main/java/com/ipseorama/slice/SingleThreadNioIceEngine.java @@ -331,10 +331,14 @@ private Long tx() { if (far != null) { Log.verb(StunPacket.hexString(sp.getTid()) + " sending packet type " + sp.getClass().getSimpleName() + " length " + o.length + " to " + far); ByteBuffer src = ByteBuffer.wrap(o); - if (ch.isConnected()) { - ch.write(src); + if (ch.isOpen()) { + if (ch.isConnected()) { + ch.write(src); + } else { + ch.send(src, far); + } } else { - ch.send(src, far); + Log.debug("chanel is closed "+ch); } } else { Log.verb("not sending packet to unresolved address"); diff --git a/src/main/java/com/ipseorama/slice/stun/IceStunBindingTransaction.java b/src/main/java/com/ipseorama/slice/stun/IceStunBindingTransaction.java index 3b870de..868aa57 100644 --- a/src/main/java/com/ipseorama/slice/stun/IceStunBindingTransaction.java +++ b/src/main/java/com/ipseorama/slice/stun/IceStunBindingTransaction.java @@ -106,7 +106,7 @@ public void receivedReply(StunPacket r) { if (this._far.equals(reflex)){ Log.debug("far ip confirmed as "+reflex); } else { - Log.info("new Ip found (peer reflexive) "+reflex+" on "+this.candidatePair); + Log.debug("new Ip found (peer reflexive) "+reflex+" on "+this.candidatePair); } if (oncomplete != null) { oncomplete.onEvent(this);