Skip to content

fix: original msg id in GetMessageOrigData, netadr_ip 64-bit OOB, param bounds abort - #390

Open
Nord1cWarr1or wants to merge 1 commit into
rehlds:masterfrom
Nord1cWarr1or:fix/natives-bugs
Open

fix: original msg id in GetMessageOrigData, netadr_ip 64-bit OOB, param bounds abort#390
Nord1cWarr1or wants to merge 1 commit into
rehlds:masterfrom
Nord1cWarr1or:fix/natives-bugs

Conversation

@Nord1cWarr1or

Copy link
Copy Markdown
Member

Description

This PR fixes three bugs in the message-hook and netaddr natives, one per issue.

1. GetMessageOrigData(MsgMsgId) returned the current message id — Fixes #387

GetMessageOrigData with MsgMsgId returned the current id (getId()) instead of the original one (getOriginalId()), breaking the native's contract. All other *Orig* branches already used the original getters, and getOriginalId() has always been part of the IMessageContext interface (IMessageManager.h).

2. Out-of-bounds write/read of netadr_s.ip[4] via size_t cast — Fixes #388

set_netadr / get_netadr cast netadr_s.ip (a unsigned char ip[4] field) to size_t * and wrote/read through it. On LP64 size_t is 8 bytes, so 8 bytes were written into a 4-byte field, clobbering the adjacent port and the head of ipx[10] — out-of-bounds access on 64-bit builds.

The cast is changed to unsigned int (4 bytes on both ILP32 and LP64): the OOB is gone, and 32-bit behavior/codegen is unchanged since sizeof(size_t) == sizeof(unsigned int) == 4 there.

3. CHECK_PARAMBOUNDS logged an error but did not abort the native — Fixes #389

The macro reported an AMX runtime error but did not return, so the native kept executing with the out-of-bounds argument. Added return FALSE; to the macro body. All six use sites (SetMessageData, GetMessageData, GetMessageOrigData, GetMessageArgType, IsMessageDataModified, ResetModifiedMessageData) were audited — each one is a cell-returning native with an existing FALSE error path, so the abort is consistent with the file's error convention.

Validation

  • Full Linux 32-bit build (same flags as CI): builds and links cleanly (reapi_amxx_i386.so); the two changed translation units compile with no warnings.
  • 64-bit (-m64) syntax-only compile of the changed translation units: clean.
  • Offsets verified against netadr_s layout (common/netadr.h): type (4 bytes) followed by ip[4], so ip is 4-byte aligned and a 4-byte access is exactly the field width.

Fixes #387, Fixes #388, Fixes #389

…am bounds abort

- GetMessageOrigData(MsgMsgId) returned the current message id
  (getId()); use getOriginalId() like the other Original-branches do
  (rehlds#387)
- set_netadr/get_netadr wrote/read 8 bytes into the 4-byte netadr_s.ip
  field through a size_t cast - OOB on 64-bit builds; use unsigned int,
  32-bit behavior unchanged (rehlds#388)
- CHECK_PARAMBOUNDS now aborts the native (return FALSE) after logging
  instead of continuing with the out-of-bounds argument; all six
  use-sites reviewed, every caller already has FALSE error paths
  (rehlds#389)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant