From 11b84bc2b9c14f662dbb7b415ac2c170d51876df Mon Sep 17 00:00:00 2001 From: Philipp Jungkamp Date: Wed, 29 Jun 2022 20:24:23 +0000 Subject: [PATCH] Fix out of bounds vector access --- lib/nodes/iec60870.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nodes/iec60870.cpp b/lib/nodes/iec60870.cpp index 2e15c370c..868b0211f 100644 --- a/lib/nodes/iec60870.cpp +++ b/lib/nodes/iec60870.cpp @@ -514,7 +514,7 @@ int SlaveNode::_write(Sample *samples[], unsigned sample_count) // update last_values this->output.last_values_mutex.lock(); - for (unsigned i = 0; i < sample->length; i++) { + for (unsigned i = 0; i < MIN(sample->length, this->output.last_values.size()); i++) { this->output.last_values[i] = sample->data[i]; } this->output.last_values_mutex.unlock();