Skip to content

CHECK_PARAMBOUNDS macro logs an error but does not abort the native #389

Description

@Nord1cWarr1or

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions