You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by jm...@apache.org on 2018/01/04 05:19:20 UTC

[incubator-plc4x] 01/05: stop RTE when passing empty or null messages

This is an automated email from the ASF dual-hosted git repository.

jmclean pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-plc4x.git

commit 2d1b219219c693647f33632a4a6b7bb020ea9766
Author: Justin Mclean <jm...@apache.org>
AuthorDate: Thu Jan 4 16:13:43 2018 +1100

    stop RTE when passing empty or null messages
---
 .../org/apache/plc4x/java/isotp/netty/IsoTPProtocol.java     | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/plc4j/protocols/s7/src/main/java/org/apache/plc4x/java/isotp/netty/IsoTPProtocol.java b/plc4j/protocols/s7/src/main/java/org/apache/plc4x/java/isotp/netty/IsoTPProtocol.java
index 2271312..e33d0b9 100644
--- a/plc4j/protocols/s7/src/main/java/org/apache/plc4x/java/isotp/netty/IsoTPProtocol.java
+++ b/plc4j/protocols/s7/src/main/java/org/apache/plc4x/java/isotp/netty/IsoTPProtocol.java
@@ -77,6 +77,10 @@ public class IsoTPProtocol extends MessageToMessageCodec<IsoOnTcpMessage, Tpdu>
     @Override
     protected void encode(ChannelHandlerContext ctx, Tpdu in, List<Object> out) throws Exception {
         logger.debug("ISO Transport Protocol Message sent");
+        
+        if (in == null) {
+            return;
+        }
 
         ByteBuf buf = Unpooled.buffer();
 
@@ -139,7 +143,15 @@ public class IsoTPProtocol extends MessageToMessageCodec<IsoOnTcpMessage, Tpdu>
         }
         logger.debug("ISO TP Message received");
 
+        if (in == null) {
+            return;
+        }
+
         ByteBuf userData = in.getUserData();
+        if (userData.writerIndex() < 1) {
+            return;
+        }
+        
         int packetStart = userData.readerIndex();
         byte headerLength = userData.readByte();
         int headerEnd = packetStart + headerLength;

-- 
To stop receiving notification emails like this one, please contact
"commits@plc4x.apache.org" <co...@plc4x.apache.org>.