diff --git a/doc/changes/state_trackers/mr.359.16.md b/doc/changes/state_trackers/mr.359.16.md new file mode 100644 index 000000000..23bbf4178 --- /dev/null +++ b/doc/changes/state_trackers/mr.359.16.md @@ -0,0 +1,2 @@ +OpenXR: Validate the arguments for `xrSuggestInteractionProfileBindings` better +so that it follows the spec better. diff --git a/src/xrt/state_trackers/oxr/oxr_api_action.c b/src/xrt/state_trackers/oxr/oxr_api_action.c index bcc6fb43d..7a69e27c5 100644 --- a/src/xrt/state_trackers/oxr/oxr_api_action.c +++ b/src/xrt/state_trackers/oxr/oxr_api_action.c @@ -7,8 +7,6 @@ * @ingroup oxr_api */ -#include <stdio.h> - #include "oxr_objects.h" #include "oxr_logger.h" #include "oxr_handle.h" @@ -18,6 +16,9 @@ #include "oxr_api_funcs.h" #include "oxr_api_verify.h" +#include <stdio.h> +#include <inttypes.h> + /* * @@ -98,12 +99,34 @@ oxr_xrSuggestInteractionProfileBindings( &log, suggestedBindings, XR_TYPE_INTERACTION_PROFILE_SUGGESTED_BINDING); + if (suggestedBindings->countSuggestedBindings == 0) { + return oxr_error(&log, XR_ERROR_VALIDATION_FAILURE, + "(suggestedBindings->countSuggestedBindings " + "== 0) can not suggest 0 bindings"); + } + for (size_t i = 0; i < suggestedBindings->countSuggestedBindings; i++) { const XrActionSuggestedBinding *s = &suggestedBindings->suggestedBindings[i]; - struct oxr_action *dummy; - OXR_VERIFY_ACTION_NOT_NULL(&log, s->action, dummy); + struct oxr_action *act; + OXR_VERIFY_ACTION_NOT_NULL(&log, s->action, act); + + if (act->act_set->attached) { + return oxr_error( + &log, XR_ERROR_ACTIONSETS_ALREADY_ATTACHED, + "(suggestedBindings->suggestedBindings[%zu]->" + "action) action '%s/%s' has already been attached", + i, act->act_set->name, act->name); + } + + if (!oxr_path_is_valid(&log, inst, s->binding)) { + return oxr_error( + &log, XR_ERROR_PATH_INVALID, + "(suggestedBindings->suggestedBindings[%zu]->" + "binding == %" PRIu64 ") is not a valid path", + i, s->binding); + } //! @todo verify path (s->binding). }