summaryrefslogtreecommitdiffstats
path: root/thirdparty/openxr/src/loader/api_layer_interface.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty/openxr/src/loader/api_layer_interface.cpp')
-rw-r--r--thirdparty/openxr/src/loader/api_layer_interface.cpp46
1 files changed, 27 insertions, 19 deletions
diff --git a/thirdparty/openxr/src/loader/api_layer_interface.cpp b/thirdparty/openxr/src/loader/api_layer_interface.cpp
index b946e09402..c9e24ec40b 100644
--- a/thirdparty/openxr/src/loader/api_layer_interface.cpp
+++ b/thirdparty/openxr/src/loader/api_layer_interface.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2022, The Khronos Group Inc.
+// Copyright (c) 2017-2023, The Khronos Group Inc.
// Copyright (c) 2017-2019 Valve Corporation
// Copyright (c) 2017-2019 LunarG, Inc.
//
@@ -82,6 +82,12 @@ XrResult ApiLayerInterface::GetApiLayerProperties(const std::string& openxr_comm
return result;
}
+ // check for potential overflow before static_cast<uint32_t>
+ if (manifest_files.size() >= UINT32_MAX) {
+ LoaderLogger::LogErrorMessage(openxr_command, "ApiLayerInterface::GetApiLayerProperties - too many API layers found");
+ return XR_ERROR_RUNTIME_FAILURE;
+ }
+
manifest_count = static_cast<uint32_t>(manifest_files.size());
if (nullptr == outgoing_count) {
LoaderLogger::LogErrorMessage("xrEnumerateInstanceExtensionProperties",
@@ -131,8 +137,8 @@ XrResult ApiLayerInterface::GetInstanceExtensionProperties(const std::string& op
}
bool found = false;
- auto num_files = static_cast<uint32_t>(manifest_files.size());
- for (uint32_t man_file = 0; man_file < num_files; ++man_file) {
+ size_t num_files = manifest_files.size();
+ for (size_t man_file = 0; man_file < num_files; ++man_file) {
// If a layer with the provided name exists, get it's instance extension information.
if (manifest_files[man_file]->LayerName() == layer_name) {
manifest_files[man_file]->GetInstanceExtensionProperties(extension_properties);
@@ -172,8 +178,8 @@ XrResult ApiLayerInterface::GetInstanceExtensionProperties(const std::string& op
}
// Grab the layer instance extensions information
- auto num_files = static_cast<uint32_t>(manifest_files.size());
- for (uint32_t man_file = 0; man_file < num_files; ++man_file) {
+ size_t num_files = manifest_files.size();
+ for (size_t man_file = 0; man_file < num_files; ++man_file) {
manifest_files[man_file]->GetInstanceExtensionProperties(extension_properties);
}
}
@@ -231,21 +237,23 @@ XrResult ApiLayerInterface::LoadApiLayers(const std::string& openxr_command, uin
for (const auto& layer_name : enabled_explicit_api_layer_names) {
bool found_this_layer = false;
- for (auto it = explicit_layer_manifest_files.begin(); it != explicit_layer_manifest_files.end();) {
- bool erased_layer_manifest_file = false;
-
- if (layers_already_found.count(layer_name) > 0) {
- found_this_layer = true;
- } else if (layer_name == (*it)->LayerName()) {
- found_this_layer = true;
- layers_already_found.insert(layer_name);
- enabled_layer_manifest_files_in_init_order.push_back(std::move(*it));
- it = explicit_layer_manifest_files.erase(it);
- erased_layer_manifest_file = true;
- }
+ if (layers_already_found.count(layer_name) > 0) {
+ found_this_layer = true;
+ } else {
+ for (auto it = explicit_layer_manifest_files.begin(); it != explicit_layer_manifest_files.end();) {
+ bool erased_layer_manifest_file = false;
+
+ if (layer_name == (*it)->LayerName()) {
+ found_this_layer = true;
+ layers_already_found.insert(layer_name);
+ enabled_layer_manifest_files_in_init_order.push_back(std::move(*it));
+ it = explicit_layer_manifest_files.erase(it);
+ erased_layer_manifest_file = true;
+ }
- if (!erased_layer_manifest_file) {
- it++;
+ if (!erased_layer_manifest_file) {
+ it++;
+ }
}
}