mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Validate json root is an object before trying to retrieve members from it.
This commit is contained in:
parent
5c3b7d1b56
commit
51dd17ad2a
@ -40,6 +40,12 @@ void CBanSystem::LoadList(void)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!document.IsObject())
|
||||
{
|
||||
Warning(eDLL_T::SERVER, "%s: JSON root was not an object\n", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
uint64_t nTotalBans = 0;
|
||||
if (document.HasMember("totalBans") && document["totalBans"].IsUint64())
|
||||
{
|
||||
|
@ -337,6 +337,12 @@ bool CPylon::SendRequest(const char* endpoint, const rapidjson::Document& reques
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!responseJson.IsObject())
|
||||
{
|
||||
Warning(eDLL_T::SERVER, "%s: JSON root was not an object\n", __FUNCTION__);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pylon_showdebuginfo->GetBool())
|
||||
{
|
||||
LogBody(responseJson);
|
||||
@ -429,7 +435,8 @@ bool CPylon::QueryServer(const char* endpoint, const char* request,
|
||||
void CPylon::ExtractError(const rapidjson::Document& resultJson, string& outMessage,
|
||||
CURLINFO status, const char* errorText) const
|
||||
{
|
||||
if (resultJson.HasMember("error") &&
|
||||
|
||||
if (resultJson.IsObject() && resultJson.HasMember("error") &&
|
||||
resultJson["error"].IsString())
|
||||
{
|
||||
outMessage = resultJson["error"].GetString();
|
||||
|
Loading…
x
Reference in New Issue
Block a user