Summary
The CHECK_PARAMBOUNDS macro in reapi/src/natives/natives_hookmessage.cpp reports an AMX runtime error but does not return, so the native keeps executing with the out-of-bounds value. Safety currently relies on the engine-side bounds checks downstream, and the post-error behavior is undefined from the plugin author's point of view (the native may still return a value after AMXX already reported an error).
Evidence
reapi/src/natives/natives_hookmessage.cpp:3:
#define CHECK_PARAMBOUNDS(x, y) if (unlikely(x > (size_t)y)) { AMXX_LogError(amx, AMX_ERR_NATIVE, "%s: invalid message argument %d/max:%d", __FUNCTION__, x, y); }
Example consequence: IsMessageDataModified(MsgArg, -1) — number is used as params[arg_number] - 1, so -1 becomes SIZE_MAX - 2; the macro logs the error, execution continues, and the engine's isDataModified() bounds check just returns FALSE.
Suggested fix
Audit all use sites (grep -n CHECK_PARAMBOUNDS reapi/src), then add return FALSE; to the macro body so the native aborts after reporting the error:
#define CHECK_PARAMBOUNDS(x, y) if (unlikely(x > (size_t)y)) { AMXX_LogError(amx, AMX_ERR_NATIVE, "%s: invalid message argument %d/max:%d", __FUNCTION__, x, y); return FALSE; }
Environment
- ReAPI module, current master (verified on local checkout, commit 0686229)
Summary
The
CHECK_PARAMBOUNDSmacro inreapi/src/natives/natives_hookmessage.cppreports an AMX runtime error but does not return, so the native keeps executing with the out-of-bounds value. Safety currently relies on the engine-side bounds checks downstream, and the post-error behavior is undefined from the plugin author's point of view (the native may still return a value after AMXX already reported an error).Evidence
reapi/src/natives/natives_hookmessage.cpp:3:Example consequence:
IsMessageDataModified(MsgArg, -1)—numberis used asparams[arg_number] - 1, so-1becomesSIZE_MAX - 2; the macro logs the error, execution continues, and the engine'sisDataModified()bounds check just returnsFALSE.Suggested fix
Audit all use sites (
grep -n CHECK_PARAMBOUNDS reapi/src), then addreturn FALSE;to the macro body so the native aborts after reporting the error:Environment