You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by cd...@apache.org on 2019/02/21 13:21:43 UTC
[incubator-plc4x] branch develop updated: PLC4X-84 - NPE when
reading Marker
This is an automated email from the ASF dual-hosted git repository.
cdutz pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-plc4x.git
The following commit(s) were added to refs/heads/develop by this push:
new 78f84b4 PLC4X-84 - NPE when reading Marker
78f84b4 is described below
commit 78f84b413db76959e4732d2eedb431389ce55bc5
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Thu Feb 21 14:21:40 2019 +0100
PLC4X-84 - NPE when reading Marker
- Made the protocol throw an exception if an unknown memory area is referenced.
---
.../src/main/java/org/apache/plc4x/java/s7/netty/S7Protocol.java | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/plc4j/protocols/s7/src/main/java/org/apache/plc4x/java/s7/netty/S7Protocol.java b/plc4j/protocols/s7/src/main/java/org/apache/plc4x/java/s7/netty/S7Protocol.java
index b3b5a87..17214ca 100644
--- a/plc4j/protocols/s7/src/main/java/org/apache/plc4x/java/s7/netty/S7Protocol.java
+++ b/plc4j/protocols/s7/src/main/java/org/apache/plc4x/java/s7/netty/S7Protocol.java
@@ -28,6 +28,7 @@ import io.netty.util.concurrent.PromiseCombiner;
import org.apache.commons.lang3.reflect.FieldUtils;
import org.apache.plc4x.java.api.exceptions.PlcProtocolException;
import org.apache.plc4x.java.api.exceptions.PlcProtocolPayloadTooBigException;
+import org.apache.plc4x.java.api.exceptions.PlcRuntimeException;
import org.apache.plc4x.java.isotp.protocol.IsoTPProtocol;
import org.apache.plc4x.java.isotp.protocol.events.IsoTPConnectedEvent;
import org.apache.plc4x.java.isotp.protocol.model.IsoTPMessage;
@@ -757,7 +758,11 @@ public class S7Protocol extends ChannelDuplexHandler {
TransportSize dataType = TransportSize.valueOf(in.readByte());
short length = in.readShort();
short dbNumber = in.readShort();
- MemoryArea memoryArea = MemoryArea.valueOf(in.readByte());
+ byte memoryAreaCode = in.readByte();
+ MemoryArea memoryArea = MemoryArea.valueOf(memoryAreaCode);
+ if(memoryArea == null) {
+ throw new PlcRuntimeException("Unknown memory area '" + memoryAreaCode + "'");
+ }
short byteAddress = (short) (in.readShort() << 5);
byte tmp = in.readByte();
// Only the least 3 bits are the bit address, the