diff --git a/src/wmbus.cc b/src/wmbus.cc index 54e2dad..8057e65 100644 --- a/src/wmbus.cc +++ b/src/wmbus.cc @@ -4126,6 +4126,8 @@ bool BusDeviceCommonImplementation::handleTelegram(AboutTelegram &about, vector< bool handled = false; last_received_ = time(NULL); + assert(frame.size() > 0); + if (about.type == FrameType::MBUS && frame.size() == 1) { if (frame[0] == 0xe5) diff --git a/src/wmbus_rawtty.cc b/src/wmbus_rawtty.cc index 8bcd559..a8535a6 100644 --- a/src/wmbus_rawtty.cc +++ b/src/wmbus_rawtty.cc @@ -211,6 +211,14 @@ void WMBusRawTTY::processSerialData() { FrameStatus status = checkWMBusFrame(data_buffer_, &frame_length, &payload_len, &payload_offset, false); + if (payload_len == 0) + { + verbose("(rawtty) protocol error in message received length byte is zero!\n"); + string msg = bin2hex(data_buffer_); + debug("(rawtty) protocol error \"%s\"\n", msg.c_str()); + data_buffer_.clear(); + break; + } if (status == PartialFrame) { // Partial frame, stop eating.