mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2024-11-11 12:45:05 +01:00
fixup! fix num_client_certs in CloseClientCertContext
This commit is contained in:
parent
10ef3109a4
commit
dfb82b4dfd
@ -309,33 +309,18 @@ void HTTP_C::OpenClientCertContext(Kernel::HLERequestContext& ctx) {
|
|||||||
auto* session_data = GetSessionData(ctx.Session());
|
auto* session_data = GetSessionData(ctx.Session());
|
||||||
ASSERT(session_data);
|
ASSERT(session_data);
|
||||||
|
|
||||||
|
ResultCode result(RESULT_SUCCESS);
|
||||||
|
|
||||||
if (!session_data->initialized) {
|
if (!session_data->initialized) {
|
||||||
LOG_ERROR(Service_HTTP, "Command called without Initialize");
|
LOG_ERROR(Service_HTTP, "Command called without Initialize");
|
||||||
IPC::RequestBuilder rb = rp.MakeBuilder(1, 4);
|
result = ERROR_STATE_ERROR;
|
||||||
rb.Push(ERROR_STATE_ERROR);
|
} else if (session_data->current_http_context != boost::none) {
|
||||||
rb.PushMappedBuffer(cert_buffer);
|
|
||||||
rb.PushMappedBuffer(key_buffer);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (session_data->current_http_context != boost::none) {
|
|
||||||
LOG_ERROR(Service_HTTP, "Command called with a bound context");
|
LOG_ERROR(Service_HTTP, "Command called with a bound context");
|
||||||
IPC::RequestBuilder rb = rp.MakeBuilder(1, 4);
|
result = ERROR_NOT_IMPLEMENTED;
|
||||||
rb.Push(ERROR_NOT_IMPLEMENTED);
|
} else if (session_data->num_client_certs >= 2) {
|
||||||
rb.PushMappedBuffer(cert_buffer);
|
|
||||||
rb.PushMappedBuffer(key_buffer);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (session_data->num_client_certs >= 2) {
|
|
||||||
LOG_ERROR(Service_HTTP, "tried to load more then 2 client certs");
|
LOG_ERROR(Service_HTTP, "tried to load more then 2 client certs");
|
||||||
IPC::RequestBuilder rb = rp.MakeBuilder(1, 4);
|
result = ERROR_TOO_MANY_CLIENT_CERTS;
|
||||||
rb.Push(ERROR_TOO_MANY_CLIENT_CERTS);
|
} else {
|
||||||
rb.PushMappedBuffer(cert_buffer);
|
|
||||||
rb.PushMappedBuffer(key_buffer);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
++client_certs_counter;
|
++client_certs_counter;
|
||||||
client_certs[client_certs_counter].handle = client_certs_counter;
|
client_certs[client_certs_counter].handle = client_certs_counter;
|
||||||
client_certs[client_certs_counter].certificate.resize(cert_size);
|
client_certs[client_certs_counter].certificate.resize(cert_size);
|
||||||
@ -345,16 +330,16 @@ void HTTP_C::OpenClientCertContext(Kernel::HLERequestContext& ctx) {
|
|||||||
client_certs[client_certs_counter].session_id = session_data->session_id;
|
client_certs[client_certs_counter].session_id = session_data->session_id;
|
||||||
|
|
||||||
++session_data->num_client_certs;
|
++session_data->num_client_certs;
|
||||||
|
}
|
||||||
|
|
||||||
LOG_DEBUG(Service_HTTP, "called, cert_size {}, key_size {}", cert_size, key_size);
|
LOG_DEBUG(Service_HTTP, "called, cert_size {}, key_size {}", cert_size, key_size);
|
||||||
IPC::RequestBuilder rb = rp.MakeBuilder(1, 4);
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 4);
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(result);
|
||||||
rb.PushMappedBuffer(cert_buffer);
|
rb.PushMappedBuffer(cert_buffer);
|
||||||
rb.PushMappedBuffer(key_buffer);
|
rb.PushMappedBuffer(key_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HTTP_C::OpenDefaultClientCertContext(Kernel::HLERequestContext& ctx) {
|
void HTTP_C::OpenDefaultClientCertContext(Kernel::HLERequestContext& ctx) {
|
||||||
constexpr u8 default_cert_id = 0x40;
|
|
||||||
IPC::RequestParser rp(ctx, 0x33, 1, 0);
|
IPC::RequestParser rp(ctx, 0x33, 1, 0);
|
||||||
u8 cert_id = rp.Pop<u8>();
|
u8 cert_id = rp.Pop<u8>();
|
||||||
|
|
||||||
@ -382,6 +367,7 @@ void HTTP_C::OpenDefaultClientCertContext(Kernel::HLERequestContext& ctx) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr u8 default_cert_id = 0x40;
|
||||||
if (cert_id != default_cert_id) {
|
if (cert_id != default_cert_id) {
|
||||||
LOG_ERROR(Service_HTTP, "called with invalid cert_id {}", cert_id);
|
LOG_ERROR(Service_HTTP, "called with invalid cert_id {}", cert_id);
|
||||||
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
||||||
@ -396,7 +382,7 @@ void HTTP_C::OpenDefaultClientCertContext(Kernel::HLERequestContext& ctx) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto it = std::find_if(client_certs.begin(), client_certs.end(),
|
const auto& it = std::find_if(client_certs.begin(), client_certs.end(),
|
||||||
[default_cert_id, &session_data](const auto& i) {
|
[default_cert_id, &session_data](const auto& i) {
|
||||||
return default_cert_id == i.second.cert_id &&
|
return default_cert_id == i.second.cert_id &&
|
||||||
session_data->session_id == i.second.session_id;
|
session_data->session_id == i.second.session_id;
|
||||||
|
Loading…
Reference in New Issue
Block a user