Fix ClientPrefs pointer string formatting (#2307)
Some checks failed
Continuous Integration / ${{ matrix.os_short }}-${{ matrix.compiler_cc }} (clang, clang++, ubuntu-latest, linux) (push) Has been cancelled
Continuous Integration / ${{ matrix.os_short }}-${{ matrix.compiler_cc }} (clang-8, clang++-8, ubuntu-20.04, linux) (push) Has been cancelled
Continuous Integration / ${{ matrix.os_short }}-${{ matrix.compiler_cc }} (msvc, windows-latest, win) (push) Has been cancelled
hl2sdk-mock tests / mock (push) Has been cancelled
SourcePawn scripting / build (ubuntu-latest, linux) (push) Has been cancelled
SourcePawn scripting / build (windows-latest, win) (push) Has been cancelled

* Fix pointer to string marshaling in ClientPrefs for x64

* Fix other cases where pointers were formatted with %x

* Fix warnings in ClientPrefs IsAuthIdConnected
This commit is contained in:
Nicholas Hastings 2025-03-31 17:21:54 -04:00 committed by GitHub
parent f896c4a24d
commit 30da01763d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 12 additions and 13 deletions

View File

@ -129,7 +129,7 @@ void DebugReport::GenerateCodeError(IPluginContext *pContext, uint32_t code_addr
{
g_Logger.LogError("[SM] Unable to call function \"%s\" due to above error(s).", name);
} else {
g_Logger.LogError("[SM] Unable to call function (name unknown, address \"%x\").", code_addr);
g_Logger.LogError("[SM] Unable to call function (name unknown, address \"%p\").", code_addr);
}
}

View File

@ -875,7 +875,7 @@ static cell_t LoadFromAddress(IPluginContext *pContext, const cell_t *params)
}
else if (reinterpret_cast<uintptr_t>(addr) < VALID_MINIMUM_MEMORY_ADDRESS)
{
return pContext->ThrowNativeError("Invalid address 0x%x is pointing to reserved memory.", addr);
return pContext->ThrowNativeError("Invalid address %p is pointing to reserved memory.", addr);
}
NumberType size = static_cast<NumberType>(params[2]);
@ -907,7 +907,7 @@ static cell_t StoreToAddress(IPluginContext *pContext, const cell_t *params)
}
else if (reinterpret_cast<uintptr_t>(addr) < VALID_MINIMUM_MEMORY_ADDRESS)
{
return pContext->ThrowNativeError("Invalid address 0x%x is pointing to reserved memory.", addr);
return pContext->ThrowNativeError("Invalid address %p is pointing to reserved memory.", addr);
}
cell_t data = params[2];

View File

@ -736,7 +736,7 @@ static cell_t LoadEntityFromHandleAddress(IPluginContext *pContext, const cell_t
}
else if (reinterpret_cast<uintptr_t>(addr) < VALID_MINIMUM_MEMORY_ADDRESS)
{
return pContext->ThrowNativeError("Invalid address 0x%x is pointing to reserved memory.", addr);
return pContext->ThrowNativeError("Invalid address %p is pointing to reserved memory.", addr);
}
CBaseHandle &hndl = *reinterpret_cast<CBaseHandle*>(addr);

View File

@ -344,7 +344,7 @@ void CookieManager::OnPluginDestroyed(IPlugin *plugin)
if (strcmp(draw.display, name) == 0)
{
data = (AutoMenuData *)strtoul(info, NULL, 16);
data = (AutoMenuData *)strtoull(info, nullptr, 16);
if (data->handler->forward != NULL)
{

View File

@ -40,7 +40,7 @@ void ClientMenuHandler::OnMenuSelect(IBaseMenu *menu, int client, unsigned int i
const char *info = menu->GetItemInfo(item, &draw);
AutoMenuData *data = (AutoMenuData *)strtoul(info, NULL, 16);
AutoMenuData *data = (AutoMenuData *)strtoull(info, nullptr, 16);
if (data->handler->forward != NULL)
{
@ -94,7 +94,7 @@ unsigned int ClientMenuHandler::OnMenuDisplayItem(IBaseMenu *menu,
const char *info = menu->GetItemInfo(item, &draw);
AutoMenuData *data = (AutoMenuData *)strtoul(info, NULL, 16);
AutoMenuData *data = (AutoMenuData *)strtoull(info, nullptr, 16);
if (data->handler->forward != NULL)
{
@ -123,7 +123,7 @@ void AutoMenuHandler::OnMenuSelect(SourceMod::IBaseMenu *menu, int client, unsig
const char *info = menu->GetItemInfo(item, &draw);
AutoMenuData *data = (AutoMenuData *)strtoul(info, NULL, 16);
AutoMenuData *data = (AutoMenuData *)strtoull(info, nullptr, 16);
g_CookieManager.SetCookieValue(data->pCookie, client, settings[data->type][item]);

View File

@ -83,10 +83,9 @@ cell_t FindClientPrefCookie(IPluginContext *pContext, const cell_t *params)
NULL);
}
size_t IsAuthIdConnected(char *authID)
int IsAuthIdConnected(char *authID)
{
IGamePlayer *player;
const char *authString;
for (int playerIndex = playerhelpers->GetMaxClients()+1; --playerIndex > 0;)
{
@ -347,7 +346,7 @@ cell_t AddSettingsMenuItem(IPluginContext *pContext, const cell_t *params)
AutoMenuData *data = new AutoMenuData;
data->datavalue = params[2];
data->handler = pItem;
g_pSM->Format(info, sizeof(info), "%x", data);
g_pSM->Format(info, sizeof(info), "%" PRIxPTR, reinterpret_cast<uintptr_t>(data));
ItemDrawInfo draw(display, 0);
@ -419,7 +418,7 @@ cell_t AddSettingsPrefabMenuItem(IPluginContext *pContext, const cell_t *params)
data->pCookie = pCookie;
data->type = (CookieMenu)params[2];
data->handler = pItem;
g_pSM->Format(info, sizeof(info), "%x", data);
g_pSM->Format(info, sizeof(info), "%" PRIxPTR, reinterpret_cast<uintptr_t>(data));
g_CookieManager.clientMenu->AppendItem(info, draw);

View File

@ -406,7 +406,7 @@ static cell_t SDKCall(IPluginContext *pContext, const cell_t *params)
else if (reinterpret_cast<uintptr_t>(thisptr) < VALID_MINIMUM_MEMORY_ADDRESS)
{
vc->stk_put(ptr);
return pContext->ThrowNativeError("Invalid ThisPtr address 0x%x is pointing to reserved memory.", thisptr);
return pContext->ThrowNativeError("Invalid ThisPtr address %p is pointing to reserved memory.", thisptr);
}
*(void **)ptr = thisptr;