TNetwork: Fix crash when auth response is not a JSON object

This commit is contained in:
Lion Kortlepel
2021-08-16 14:40:58 +02:00
committed by Lion
parent 0143748953
commit 9f0b057c14
+18 -17
View File
@@ -295,23 +295,24 @@ void TNetwork::Authentication(SOCKET TCPSock) {
return; return;
} }
if (!AuthResponse.IsObject() && Rc != "0") { if (!AuthResponse.IsObject()) {
ClientKick(*Client, "Backend returned invalid auth response format."); if (Rc == "0") {
error("Backend returned invalid auth response format. This should never happen."); auto Lock = Sentry.CreateExclusiveContext();
auto Lock = Sentry.CreateExclusiveContext(); Sentry.SetContext("auth",
Sentry.SetContext("auth", { { "response-body", Rc },
{ { "response-body", Rc }, { "key", RequestString } });
{ "key", RequestString } }); Sentry.SetTransaction(Application::GetBackendUrlForAuth() + Target);
Sentry.SetTransaction(Application::GetBackendUrlForAuth() + Target); Sentry.Log(SentryLevel::Info, "default", "backend returned 0 instead of json (" + std::to_string(ResponseCode) + ")");
Sentry.Log(SentryLevel::Error, "default", "unexpected backend response (" + std::to_string(ResponseCode) + ")"); } else { // Rc != "0"
return; ClientKick(*Client, "Backend returned invalid auth response format.");
} else if (Rc == "0") { error("Backend returned invalid auth response format. This should never happen.");
auto Lock = Sentry.CreateExclusiveContext(); auto Lock = Sentry.CreateExclusiveContext();
Sentry.SetContext("auth", Sentry.SetContext("auth",
{ { "response-body", Rc }, { { "response-body", Rc },
{ "key", RequestString } }); { "key", RequestString } });
Sentry.SetTransaction(Application::GetBackendUrlForAuth() + Target); Sentry.SetTransaction(Application::GetBackendUrlForAuth() + Target);
Sentry.Log(SentryLevel::Info, "default", "backend returned 0 instead of json (" + std::to_string(ResponseCode) + ")"); Sentry.Log(SentryLevel::Error, "default", "unexpected backend response (" + std::to_string(ResponseCode) + ")");
}
return; return;
} }