godotengine / godotengine/godot-cpp
Number of given arguments should be checked in the method wrapper function
Open
enhancement
- Dominant language
- C++
- Stars
- 2.7k
- Forks
- 809
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 8
Description
Here in `__wrapped_method`, it should be checked that `num_args` is equal to, or at least equal to or larger than `sizeof...(As)`: https://github.com/GodotNativeTools/godot-cpp/blob/master/include/core/Godot.hpp#L197
If `num_args` is less than the number of arguments expected by the wrapped method, invalid reads will happen, because in `_WrappedMethod::apply`, the arguments are dereferenced without checking the bounds:
```cpp
template
void apply(Variant *ret, T *obj, Variant **args, __Sequence) {
*ret = (obj->*f)(_ArgCast::_arg_cast(*args[I])...);
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.