From 4516ed9b226a6fa6afa5dc659ce4ba11125f4f9c Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 23 Jul 2020 17:42:35 -0500 Subject: [PATCH] st/oxr: More strictly verify xrSyncActions input in advance. --- src/xrt/state_trackers/oxr/oxr_api_action.c | 2 +- src/xrt/state_trackers/oxr/oxr_api_verify.h | 6 +++- src/xrt/state_trackers/oxr/oxr_verify.c | 39 ++++++++++++--------- 3 files changed, 28 insertions(+), 19 deletions(-) diff --git a/src/xrt/state_trackers/oxr/oxr_api_action.c b/src/xrt/state_trackers/oxr/oxr_api_action.c index c05af759e..57a244b21 100644 --- a/src/xrt/state_trackers/oxr/oxr_api_action.c +++ b/src/xrt/state_trackers/oxr/oxr_api_action.c @@ -157,7 +157,7 @@ oxr_xrSyncActions(XrSession session, const XrActionsSyncInfo *syncInfo) struct oxr_action_set *act_set = NULL; OXR_VERIFY_ACTIONSET_NOT_NULL(&log, syncInfo->activeActionSets[i].actionSet, act_set); - XrResult res = oxr_verify_subaction_path_sync(&log, sess->sys->inst, + XrResult res = oxr_verify_subaction_path_sync(&log, sess->sys->inst, act_set, syncInfo->activeActionSets[i].subactionPath, i); if (res != XR_SUCCESS) { return res; diff --git a/src/xrt/state_trackers/oxr/oxr_api_verify.h b/src/xrt/state_trackers/oxr/oxr_api_verify.h index b323ed8e9..e1b135621 100644 --- a/src/xrt/state_trackers/oxr/oxr_api_verify.h +++ b/src/xrt/state_trackers/oxr/oxr_api_verify.h @@ -276,7 +276,11 @@ oxr_verify_subaction_paths_create(struct oxr_logger *log, * Verify a set of subaction paths for action sync. */ XrResult -oxr_verify_subaction_path_sync(struct oxr_logger *log, const struct oxr_instance *inst, XrPath path, uint32_t index); +oxr_verify_subaction_path_sync(struct oxr_logger *log, + const struct oxr_instance *inst, + const struct oxr_action_set *act_set, + XrPath path, + uint32_t index); /*! * Verify a set of subaction paths for action state get. diff --git a/src/xrt/state_trackers/oxr/oxr_verify.c b/src/xrt/state_trackers/oxr/oxr_verify.c index 907db17e9..d8b9083ae 100644 --- a/src/xrt/state_trackers/oxr/oxr_verify.c +++ b/src/xrt/state_trackers/oxr/oxr_verify.c @@ -317,28 +317,33 @@ oxr_verify_subaction_paths_create(struct oxr_logger *log, } XrResult -oxr_verify_subaction_path_sync(struct oxr_logger *log, const struct oxr_instance *inst, XrPath path, uint32_t index) +oxr_verify_subaction_path_sync(struct oxr_logger *log, + const struct oxr_instance *inst, + const struct oxr_action_set *act_set, + XrPath path, + uint32_t index) { -#define VERIFY_PATH(X) \ - else if (path == inst->path_cache.X) \ - { \ - return XR_SUCCESS; \ - } if (path == XR_NULL_PATH) { return XR_SUCCESS; } - OXR_FOR_EACH_SUBACTION_PATH(VERIFY_PATH) + struct oxr_subaction_paths subaction_paths = {0}; + if (!oxr_classify_subaction_paths(log, inst, 1, &path, &subaction_paths)) { + const char *str = NULL; + size_t length = 0; -#undef VERIFY_PATH - - const char *str = NULL; - size_t length = 0; - - oxr_path_get_string(log, inst, path, &str, &length); - return oxr_error(log, XR_ERROR_PATH_INVALID, - "(actionSets[%i].subactionPath == '%s') path " - "is not a valid subaction path.", - index, str); + oxr_path_get_string(log, inst, path, &str, &length); + return oxr_error(log, XR_ERROR_PATH_INVALID, + "(actionSets[%i].subactionPath == '%s') path " + "is not a valid subaction path.", + index, str); + } + if (!oxr_subaction_paths_is_subset_of(&subaction_paths, &(act_set->data->permitted_subaction_paths))) { + return oxr_error(log, XR_ERROR_PATH_UNSUPPORTED, + "(actionSets[%i].subactionPath) action set '%s' has no " + "actions defined with the specified subaction path", + index, act_set != NULL ? act_set->data->name : "NULL"); + } + return XR_SUCCESS; } XrResult