summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2020-03-24 10:40:34 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2020-03-24 10:40:34 +0100
commit69525b18ee7dc8cb6b56b047ed48bbe870f00e5f (patch)
treeb9bcf186bd62a1bf163468a6773b052ce273e1e5
parentd0b77935d6aabf5d50e366ae2cec577b56163a3e (diff)
downloaddabmod-69525b18ee7dc8cb6b56b047ed48bbe870f00e5f.tar.gz
dabmod-69525b18ee7dc8cb6b56b047ed48bbe870f00e5f.tar.bz2
dabmod-69525b18ee7dc8cb6b56b047ed48bbe870f00e5f.zip
Pull common code c8defb3
-rw-r--r--lib/edi/common.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/edi/common.cpp b/lib/edi/common.cpp
index 8d99619..c892425 100644
--- a/lib/edi/common.cpp
+++ b/lib/edi/common.cpp
@@ -310,13 +310,20 @@ bool TagDispatcher::decode_tagpacket(const vector<uint8_t> &payload)
uint32_t taglength = read_32b(payload.begin() + i + 4);
if (taglength % 8 != 0) {
- etiLog.log(warn, "Invalid tag length!");
+ etiLog.log(warn, "Invalid EDI tag length, not multiple of 8!");
break;
}
taglength /= 8;
length = taglength;
+ const size_t calculated_length = i + 8 + taglength;
+ if (calculated_length > payload.size()) {
+ etiLog.log(warn, "Invalid EDI tag length: tag larger %zu than tagpacket %zu!",
+ calculated_length, payload.size());
+ break;
+ }
+
vector<uint8_t> tag_value(taglength);
copy( payload.begin() + i+8,
payload.begin() + i+8+taglength,