Skip to content

Commit 2c7efbc

Browse files
committed
web: cap selectable_layers parsing at kMaxVisibilityEntries
parseFromJson already bounded visible_layers and visible_chiplets so a malformed or oversized websocket payload can't force unbounded set inserts, but selectable_layers was iterating the whole input array. Apply the same std::min(arr.size(), kMaxVisibilityEntries) cap. Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
1 parent 4a21a77 commit 2c7efbc

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/web/src/tile_generator.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,10 @@ void TileVisibility::parseFromJson(const boost::json::object& json)
214214
has_selectable_layers = false;
215215
if (auto it = json.find("selectable_layers"); it != json.end()) {
216216
has_selectable_layers = true;
217-
for (const auto& v : it->value().as_array()) {
218-
selectable_layers.emplace(v.as_string());
217+
const auto& arr = it->value().as_array();
218+
const size_t count = std::min(arr.size(), kMaxVisibilityEntries);
219+
for (size_t i = 0; i < count; ++i) {
220+
selectable_layers.emplace(arr[i].as_string());
219221
}
220222
}
221223

0 commit comments

Comments
 (0)