aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2019-05-06 17:55:36 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2019-05-06 17:56:21 +0200
commit3a7202306c6aca5be2dad604f62063d605fd0982 (patch)
tree64e1fad19fa7cb68e5050cf2a6e53db78c15876e /lib
parent107dca66a069c5e317d040360b8aafd62c8282db (diff)
downloaddabmod-3a7202306c6aca5be2dad604f62063d605fd0982.tar.gz
dabmod-3a7202306c6aca5be2dad604f62063d605fd0982.tar.bz2
dabmod-3a7202306c6aca5be2dad604f62063d605fd0982.zip
EDI: Handle sequence counter check for incomplete AF packets
Diffstat (limited to 'lib')
-rw-r--r--lib/edi/ETIDecoder.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/edi/ETIDecoder.cpp b/lib/edi/ETIDecoder.cpp
index ffc17a4..a5d817e 100644
--- a/lib/edi/ETIDecoder.cpp
+++ b/lib/edi/ETIDecoder.cpp
@@ -156,8 +156,14 @@ ETIDecoder::decode_state_t ETIDecoder::decode_afpacket(
// read length from packet
uint32_t taglength = read_32b(input_data.begin() + 2);
uint16_t seq = read_16b(input_data.begin() + 6);
+
+ const size_t crclength = 2;
+ if (input_data.size() < AFPACKET_HEADER_LEN + taglength + crclength) {
+ return {false, 0};
+ }
+
if (m_last_seq + 1 != seq) {
- etiLog.level(warn) << "EDI AF Packet sequence error";
+ etiLog.level(warn) << "EDI AF Packet sequence error, " << seq;
}
m_last_seq = seq;
@@ -174,10 +180,6 @@ ETIDecoder::decode_state_t ETIDecoder::decode_afpacket(
return {false, 0};
}
- const size_t crclength = 2;
- if (input_data.size() < AFPACKET_HEADER_LEN + taglength + crclength) {
- return {false, 0};
- }
if (not has_crc) {
throw invalid_argument("AF packet not supported, has no CRC");