mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-29 01:48:31 +00:00
st/oxr: Do not crash on too many bindings to an action
This commit is contained in:
parent
170131bd2b
commit
0f9147c6de
|
@ -426,18 +426,22 @@ void
|
||||||
oxr_binding_find_bindings_from_key(struct oxr_logger *log,
|
oxr_binding_find_bindings_from_key(struct oxr_logger *log,
|
||||||
struct oxr_interaction_profile *p,
|
struct oxr_interaction_profile *p,
|
||||||
uint32_t key,
|
uint32_t key,
|
||||||
struct oxr_binding *bindings[OXR_MAX_BINDINGS_PER_ACTION],
|
size_t max_bounding_count,
|
||||||
size_t *binding_count)
|
struct oxr_binding **bindings,
|
||||||
|
size_t *out_binding_count)
|
||||||
{
|
{
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
*binding_count = 0;
|
*out_binding_count = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! @todo This function should be a two call function, or handle more
|
// How many bindings are we returning?
|
||||||
//! then 32 bindings.
|
|
||||||
size_t num = 0;
|
size_t num = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Loop over all app provided bindings for this profile
|
||||||
|
* and return those matching the action.
|
||||||
|
*/
|
||||||
for (size_t y = 0; y < p->binding_count; y++) {
|
for (size_t y = 0; y < p->binding_count; y++) {
|
||||||
struct oxr_binding *b = &p->bindings[y];
|
struct oxr_binding *b = &p->bindings[y];
|
||||||
|
|
||||||
|
@ -448,13 +452,16 @@ oxr_binding_find_bindings_from_key(struct oxr_logger *log,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (num >= 32) {
|
//! @todo Should return total count instead of fixed max.
|
||||||
*binding_count = num;
|
if (num >= max_bounding_count) {
|
||||||
return;
|
oxr_warn(log, "Internal limit reached, action has too many bindings!");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*binding_count = num;
|
assert(num <= max_bounding_count);
|
||||||
|
|
||||||
|
*out_binding_count = num;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct oxr_interaction_profile *
|
struct oxr_interaction_profile *
|
||||||
|
|
|
@ -684,7 +684,13 @@ get_binding(struct oxr_logger *log,
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t num = 0;
|
size_t num = 0;
|
||||||
oxr_binding_find_bindings_from_key(log, profile, act_ref->act_key, binding_points, &num);
|
oxr_binding_find_bindings_from_key( //
|
||||||
|
log, // log
|
||||||
|
profile, // p
|
||||||
|
act_ref->act_key, // key
|
||||||
|
ARRAY_SIZE(binding_points), // max_bounding_count
|
||||||
|
binding_points, // bindings
|
||||||
|
&num); // out_binding_count
|
||||||
if (num == 0) {
|
if (num == 0) {
|
||||||
oxr_slog(slog, "\t\t\tNo bindings!\n");
|
oxr_slog(slog, "\t\t\tNo bindings!\n");
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -589,10 +589,11 @@ oxr_session_binding_destroy_all(struct oxr_logger *log, struct oxr_session *sess
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
oxr_binding_find_bindings_from_key(struct oxr_logger *log,
|
oxr_binding_find_bindings_from_key(struct oxr_logger *log,
|
||||||
struct oxr_interaction_profile *profile,
|
struct oxr_interaction_profile *p,
|
||||||
uint32_t key,
|
uint32_t key,
|
||||||
struct oxr_binding *bindings[OXR_MAX_BINDINGS_PER_ACTION],
|
size_t max_bounding_count,
|
||||||
size_t *binding_count);
|
struct oxr_binding **bindings,
|
||||||
|
size_t *out_binding_count);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @public @memberof oxr_instance
|
* @public @memberof oxr_instance
|
||||||
|
|
Loading…
Reference in a new issue