summaryrefslogtreecommitdiffstats
path: root/qt-models/weightmodel.cpp
diff options
context:
space:
mode:
authorGravatar Lubomir I. Ivanov <neolit123@gmail.com>2018-06-19 03:59:33 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-06-20 09:30:58 +0900
commit06a870c232513aca96a624535d648a6e7c098e5f (patch)
treee6ed0b467310dec2ccbf1e4c6b83d026564fc4cf /qt-models/weightmodel.cpp
parent769aca9e956cd4bb7cc97be813968348f5e7f3d2 (diff)
downloadsubsurface-06a870c232513aca96a624535d648a6e7c098e5f.tar.gz
equipment: sanitize 'ws_info' loop limits
Instead of a constant or a macro for the maximum number of 'ws_info' elements the 100 literal was used. Define MAX_WS_INFO in dive.h and use it everywhere. Also clamp loops that iterate `ws_info' to MAX_WS_INFO. Prevents potential out-of-bounds reading, similarly to the previous commit about 'tank_info'. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Diffstat (limited to 'qt-models/weightmodel.cpp')
-rw-r--r--qt-models/weightmodel.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/qt-models/weightmodel.cpp b/qt-models/weightmodel.cpp
index 77114eaea..b8e9ffa5d 100644
--- a/qt-models/weightmodel.cpp
+++ b/qt-models/weightmodel.cpp
@@ -107,7 +107,7 @@ bool WeightModel::setData(const QModelIndex &index, const QVariant &value, int r
if (!ws->description || gettextFromC::tr(ws->description) != vString) {
// loop over translations to see if one matches
int i = -1;
- while (ws_info[++i].name) {
+ while (ws_info[++i].name && i < MAX_WS_INFO) {
if (gettextFromC::tr(ws_info[i].name) == vString) {
ws->description = copy_string(ws_info[i].name);
break;