summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-08-11 06:49:33 +0200
committerStanislaw Halik <sthalik@misaki.pl>2015-08-11 06:49:33 +0200
commit33286a3e74b03d1942a2ad61d69320a9434fd75a (patch)
treef825667503d66d4f8c6c6ab457a393d701db33d9
parentf0f18a08e2f4a82902098df8d54578811919fa67 (diff)
tracker-udp: prevent read past end of buffer
Can happen with incorrect .ini values.
-rwxr-xr-x[-rw-r--r--]ftnoir_tracker_udp/ftnoir_tracker_udp.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp
index bc42f402..f03e75aa 100644..100755
--- a/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp
+++ b/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp
@@ -59,7 +59,10 @@ void FTNoIR_Tracker::data(double *data)
};
for (int i = 0; i < 3; i++)
- data[Yaw + i] += values[indices[i]];
+ {
+ int k = std::min<unsigned>(sizeof(values)/sizeof(values[0]), std::max(0, indices[i]));
+ data[Yaw + i] += values[k];
+ }
}