mirror of
https://git.citron-emu.org/citron/emulator
synced 2025-12-19 10:43:33 +00:00
Merge branch 'web_backend_bug' into 'main'
fix: Use-After-Free Bug See merge request citron/emulator!94
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
// SPDX-FileCopyrightText: 2017 Citra Emulator Project
|
// SPDX-FileCopyrightText: 2017 Citra Emulator Project
|
||||||
|
// SPDX-FileCopyrightText: 2025 citron Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
@@ -75,12 +76,17 @@ struct Client::Impl {
|
|||||||
const std::string& data, const std::string& accept,
|
const std::string& data, const std::string& accept,
|
||||||
const std::string& jwt_ = "", const std::string& username_ = "",
|
const std::string& jwt_ = "", const std::string& username_ = "",
|
||||||
const std::string& token_ = "") {
|
const std::string& token_ = "") {
|
||||||
|
|
||||||
|
{
|
||||||
|
std::scoped_lock lock{cli_mutex};
|
||||||
if (cli == nullptr) {
|
if (cli == nullptr) {
|
||||||
cli = std::make_unique<httplib::Client>(host.c_str());
|
cli = std::make_unique<httplib::Client>(host.c_str());
|
||||||
cli->set_connection_timeout(TIMEOUT_SECONDS);
|
cli->set_connection_timeout(TIMEOUT_SECONDS);
|
||||||
cli->set_read_timeout(TIMEOUT_SECONDS);
|
cli->set_read_timeout(TIMEOUT_SECONDS);
|
||||||
cli->set_write_timeout(TIMEOUT_SECONDS);
|
cli->set_write_timeout(TIMEOUT_SECONDS);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!cli->is_valid()) {
|
if (!cli->is_valid()) {
|
||||||
LOG_ERROR(WebService, "Invalid URL {}", host + path);
|
LOG_ERROR(WebService, "Invalid URL {}", host + path);
|
||||||
return WebResult{WebResult::Code::InvalidURL, "Invalid URL", ""};
|
return WebResult{WebResult::Code::InvalidURL, "Invalid URL", ""};
|
||||||
@@ -162,6 +168,7 @@ struct Client::Impl {
|
|||||||
std::string token;
|
std::string token;
|
||||||
std::string jwt;
|
std::string jwt;
|
||||||
std::unique_ptr<httplib::Client> cli;
|
std::unique_ptr<httplib::Client> cli;
|
||||||
|
std::mutex cli_mutex;
|
||||||
|
|
||||||
struct JWTCache {
|
struct JWTCache {
|
||||||
std::mutex mutex;
|
std::mutex mutex;
|
||||||
|
|||||||
Reference in New Issue
Block a user