diff options
| author | Subv <subv2112@gmail.com> | 2017-10-04 12:05:13 -0500 | 
|---|---|---|
| committer | Subv <subv2112@gmail.com> | 2017-10-04 14:03:59 -0500 | 
| commit | 7b09b30ef11d1d4001a50bbb91abdfb86b954ce2 (patch) | |
| tree | 885601c5021a58356e2a5c78b06b5a76444dc8b9 /src/core/hle | |
| parent | 3c0113632dc4fb4e55b5dad9278a5b766dcaec14 (diff) | |
SVC: Replace GetPointer usage with ReadCString in ConnectToPort.
Diffstat (limited to 'src/core/hle')
| -rw-r--r-- | src/core/hle/function_wrappers.h | 15 | ||||
| -rw-r--r-- | src/core/hle/svc.cpp | 14 | 
2 files changed, 9 insertions, 20 deletions
| diff --git a/src/core/hle/function_wrappers.h b/src/core/hle/function_wrappers.h index cb0b430ee..a982b2b54 100644 --- a/src/core/hle/function_wrappers.h +++ b/src/core/hle/function_wrappers.h @@ -151,21 +151,6 @@ void Wrap() {      FuncReturn(func(PARAM(0)).raw);  } -template <ResultCode func(s64*, u32, u32*, u32)> -void Wrap() { -    FuncReturn(func((s64*)Memory::GetPointer(PARAM(0)), PARAM(1), -                    (u32*)Memory::GetPointer(PARAM(2)), (s32)PARAM(3)) -                   .raw); -} - -template <ResultCode func(u32*, const char*)> -void Wrap() { -    u32 param_1 = 0; -    u32 retval = func(¶m_1, (char*)Memory::GetPointer(PARAM(1))).raw; -    Core::CPU().SetReg(1, param_1); -    FuncReturn(retval); -} -  template <ResultCode func(u32*, s32, s32)>  void Wrap() {      u32 param_1 = 0; diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 37eeeb860..2ae177ab5 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp @@ -201,17 +201,21 @@ static ResultCode UnmapMemoryBlock(Kernel::Handle handle, u32 addr) {  }  /// Connect to an OS service given the port name, returns the handle to the port to out -static ResultCode ConnectToPort(Kernel::Handle* out_handle, const char* port_name) { -    if (port_name == nullptr) +static ResultCode ConnectToPort(Kernel::Handle* out_handle, VAddr port_name_address) { +    if (!Memory::IsValidVirtualAddress(port_name_address))          return Kernel::ERR_NOT_FOUND; -    if (std::strlen(port_name) > 11) + +    static constexpr std::size_t PortNameMaxLength = 11; +    // Read 1 char beyond the max allowed port name to detect names that are too long. +    std::string port_name = Memory::ReadCString(port_name_address, PortNameMaxLength + 1); +    if (port_name.size() > PortNameMaxLength)          return Kernel::ERR_PORT_NAME_TOO_LONG; -    LOG_TRACE(Kernel_SVC, "called port_name=%s", port_name); +    LOG_TRACE(Kernel_SVC, "called port_name=%s", port_name.c_str());      auto it = Service::g_kernel_named_ports.find(port_name);      if (it == Service::g_kernel_named_ports.end()) { -        LOG_WARNING(Kernel_SVC, "tried to connect to unknown port: %s", port_name); +        LOG_WARNING(Kernel_SVC, "tried to connect to unknown port: %s", port_name.c_str());          return Kernel::ERR_NOT_FOUND;      } | 
