aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/edi/STIDecoder.cpp2
-rw-r--r--lib/edi/STIWriter.cpp8
-rw-r--r--lib/edi/common.cpp7
3 files changed, 11 insertions, 6 deletions
diff --git a/lib/edi/STIDecoder.cpp b/lib/edi/STIDecoder.cpp
index 1f5d45e..d55cc12 100644
--- a/lib/edi/STIDecoder.cpp
+++ b/lib/edi/STIDecoder.cpp
@@ -110,7 +110,7 @@ bool STIDecoder::decode_dsti(const vector<uint8_t> &value, uint16_t)
(md.rfadf ? 9 : 0);
if (value.size() != expected_length) {
- throw std::logic_error("EDI dsti: Assertion error:"
+ throw std::runtime_error("EDI dsti: decoding error:"
"value.size() != expected_length: " +
to_string(value.size()) + " " +
to_string(expected_length));
diff --git a/lib/edi/STIWriter.cpp b/lib/edi/STIWriter.cpp
index 389a838..a7e4f20 100644
--- a/lib/edi/STIWriter.cpp
+++ b/lib/edi/STIWriter.cpp
@@ -95,7 +95,7 @@ void STIWriter::update_edi_time(
uint32_t seconds)
{
if (not m_proto_valid) {
- throw std::logic_error("Cannot update time before protocol");
+ throw std::runtime_error("Cannot update time before protocol");
}
m_utco = utco;
@@ -109,15 +109,15 @@ void STIWriter::update_edi_time(
void STIWriter::assemble()
{
if (not m_proto_valid) {
- throw std::logic_error("Cannot assemble STI before protocol");
+ throw std::runtime_error("Cannot assemble STI before protocol");
}
if (not m_management_data_valid) {
- throw std::logic_error("Cannot assemble STI before management data");
+ throw std::runtime_error("Cannot assemble STI before management data");
}
if (not m_payload_valid) {
- throw std::logic_error("Cannot assemble STI without frame data");
+ throw std::runtime_error("Cannot assemble STI without frame data");
}
// TODO check time validity
diff --git a/lib/edi/common.cpp b/lib/edi/common.cpp
index 87a15ce..e4a51b4 100644
--- a/lib/edi/common.cpp
+++ b/lib/edi/common.cpp
@@ -307,13 +307,18 @@ 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 tag length: not multiple of 8!");
break;
}
taglength /= 8;
length = taglength;
+ if (i + 8 + taglength >= payload.size()) {
+ etiLog.log(warn, "Invalid tag length: tag larger than tagpacket!");
+ break;
+ }
+
vector<uint8_t> tag_value(taglength);
copy( payload.begin() + i+8,
payload.begin() + i+8+taglength,