diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2019-05-06 17:55:36 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2019-05-06 17:56:21 +0200 |
commit | 3a7202306c6aca5be2dad604f62063d605fd0982 (patch) | |
tree | 64e1fad19fa7cb68e5050cf2a6e53db78c15876e | |
parent | 107dca66a069c5e317d040360b8aafd62c8282db (diff) | |
download | dabmod-3a7202306c6aca5be2dad604f62063d605fd0982.tar.gz dabmod-3a7202306c6aca5be2dad604f62063d605fd0982.tar.bz2 dabmod-3a7202306c6aca5be2dad604f62063d605fd0982.zip |
EDI: Handle sequence counter check for incomplete AF packets
-rw-r--r-- | lib/edi/ETIDecoder.cpp | 12 |
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"); |