From 47b21aa97e2b5bd6eff96eb368e1961f48aa8cc3 Mon Sep 17 00:00:00 2001 From: Nord1cWarr1or Date: Fri, 28 Aug 2026 11:13:58 +0300 Subject: [PATCH] fix: original msg id in GetMessageOrigData, netadr_ip 64-bit OOB, param bounds abort - GetMessageOrigData(MsgMsgId) returned the current message id (getId()); use getOriginalId() like the other Original-branches do (rehlds/ReAPI#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/ReAPI#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/ReAPI#389) --- reapi/src/natives/natives_hookmessage.cpp | 4 ++-- reapi/src/natives/natives_members.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/reapi/src/natives/natives_hookmessage.cpp b/reapi/src/natives/natives_hookmessage.cpp index ce8dba57..0d52e306 100644 --- a/reapi/src/natives/natives_hookmessage.cpp +++ b/reapi/src/natives/natives_hookmessage.cpp @@ -1,6 +1,6 @@ #include "precompiled.h" -#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); } +#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; } enum MessageHook { @@ -320,7 +320,7 @@ cell AMX_NATIVE_CALL GetMessageOrigData(AMX *amx, cell *params) case IMessage::DataType::Dest: return static_cast(g_activeMessageContext->getOriginalDest()); case IMessage::DataType::Index: - return g_activeMessageContext->getId(); + return g_activeMessageContext->getOriginalId(); case IMessage::DataType::Origin: *(Vector *)getAmxAddr(amx, params[arg_value]) = g_activeMessageContext->getOriginalOrigin(); return TRUE; diff --git a/reapi/src/natives/natives_members.cpp b/reapi/src/natives/natives_members.cpp index 368570e2..0ab79f98 100644 --- a/reapi/src/natives/natives_members.cpp +++ b/reapi/src/natives/natives_members.cpp @@ -765,7 +765,7 @@ cell AMX_NATIVE_CALL set_netadr(AMX *amx, cell *params) adr->port = ntohs(params[arg_value] & 0xFFFF); // cap short break; case netadr_ip: - *(size_t *)adr->ip = htonl(params[arg_value] & 0xFFFFFFFF); // cap int + *(unsigned int *)adr->ip = htonl(params[arg_value] & 0xFFFFFFFF); // cap int break; default: return FALSE; @@ -812,7 +812,7 @@ cell AMX_NATIVE_CALL get_netadr(AMX *amx, cell *params) setAmxString(dest, NET_AdrToString(*adr, true /*no port*/), length); } - return htonl(*(size_t *)adr->ip); + return htonl(*(unsigned int *)adr->ip); } default: break;