From daac1349dba122bec9a8a78fc0220ea49ca7c165 Mon Sep 17 00:00:00 2001 From: B3n30 Date: Mon, 23 Jul 2018 21:14:41 +0200 Subject: [PATCH] Service/HTTP_C: Add some comments; Fixed header in CloseContext --- src/core/hle/service/http_c.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/core/hle/service/http_c.cpp b/src/core/hle/service/http_c.cpp index bba46265d..72dc2a450 100644 --- a/src/core/hle/service/http_c.cpp +++ b/src/core/hle/service/http_c.cpp @@ -40,10 +40,11 @@ void HTTP_C::Initialize(Kernel::HLERequestContext& ctx) { void HTTP_C::CreateContext(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp(ctx, 0x2, 2, 2); const u32 url_size = rp.Pop(); - std::string url(url_size, '\0'); RequestMethod method = rp.PopEnum(); - Kernel::MappedBuffer& buffer = rp.PopMappedBuffer(); + + // Copy the buffer into a string without the \0 at the end of the buffer + std::string url(url_size, '\0'); buffer.Read(&url[0], 0, url_size - 1); LOG_DEBUG(Service_HTTP, "called, url_size={}, url={}, method={}", url_size, url, @@ -74,7 +75,7 @@ void HTTP_C::CreateContext(Kernel::HLERequestContext& ctx) { } void HTTP_C::CloseContext(Kernel::HLERequestContext& ctx) { - IPC::RequestParser rp(ctx, 0x3, 2, 0); + IPC::RequestParser rp(ctx, 0x3, 1, 0); u32 context_handle = rp.Pop(); @@ -104,7 +105,11 @@ void HTTP_C::AddRequestHeader(Kernel::HLERequestContext& ctx) { const u32 value_size = rp.Pop(); const std::vector name_buffer = rp.PopStaticBuffer(); Kernel::MappedBuffer& value_buffer = rp.PopMappedBuffer(); + + // Copy the name_buffer into a string without the \0 at the end const std::string name(name_buffer.begin(), name_buffer.end() - 1); + + // Copy thr value_buffer into a string without the \0 at the end std::string value(value_size - 1, '\0'); value_buffer.Read(&value[0], 0, value_size - 1);