Fix memory corruption when maximum number of parameters is exceeded (#456)
If the maximum number is exceeded fail with an informative error message. Fixes #419. Signed-off-by: Jacob Perron <jacob@openrobotics.org>
This commit is contained in:
parent
79b3ec1052
commit
ec8539b65c
3 changed files with 546 additions and 0 deletions
|
@ -1129,6 +1129,15 @@ static rcl_ret_t parse_key(
|
|||
}
|
||||
*is_new_map = false;
|
||||
}
|
||||
|
||||
// Guard against adding more than the maximum allowed parameters
|
||||
if (params_st->params[node_idx].num_params >= MAX_NUM_PARAMS_PER_NODE) {
|
||||
RCL_SET_ERROR_MSG_WITH_FORMAT_STRING(
|
||||
"Exceeded maximum allowed number of parameters for a node (%d)",
|
||||
MAX_NUM_PARAMS_PER_NODE);
|
||||
return RCL_RET_ERROR;
|
||||
}
|
||||
|
||||
/// Add a parameter name into the node parameters
|
||||
parameter_idx = params_st->params[node_idx].num_params;
|
||||
parameter_ns = ns_tracker->parameter_ns;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue