diff options
| author | 2017-10-04 12:05:13 -0500 | |
|---|---|---|
| committer | 2017-10-04 14:03:59 -0500 | |
| commit | 7b09b30ef11d1d4001a50bbb91abdfb86b954ce2 (patch) | |
| tree | 885601c5021a58356e2a5c78b06b5a76444dc8b9 /src/core/hle/svc.cpp | |
| parent | SVC: Replace GetPointer usage with ReadBlock in OutputDebugString. (diff) | |
| download | yuzu-7b09b30ef11d1d4001a50bbb91abdfb86b954ce2.tar.gz yuzu-7b09b30ef11d1d4001a50bbb91abdfb86b954ce2.tar.xz yuzu-7b09b30ef11d1d4001a50bbb91abdfb86b954ce2.zip | |
SVC: Replace GetPointer usage with ReadCString in ConnectToPort.
Diffstat (limited to 'src/core/hle/svc.cpp')
| -rw-r--r-- | src/core/hle/svc.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
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) { | |||
| 201 | } | 201 | } |
| 202 | 202 | ||
| 203 | /// Connect to an OS service given the port name, returns the handle to the port to out | 203 | /// Connect to an OS service given the port name, returns the handle to the port to out |
| 204 | static ResultCode ConnectToPort(Kernel::Handle* out_handle, const char* port_name) { | 204 | static ResultCode ConnectToPort(Kernel::Handle* out_handle, VAddr port_name_address) { |
| 205 | if (port_name == nullptr) | 205 | if (!Memory::IsValidVirtualAddress(port_name_address)) |
| 206 | return Kernel::ERR_NOT_FOUND; | 206 | return Kernel::ERR_NOT_FOUND; |
| 207 | if (std::strlen(port_name) > 11) | 207 | |
| 208 | static constexpr std::size_t PortNameMaxLength = 11; | ||
| 209 | // Read 1 char beyond the max allowed port name to detect names that are too long. | ||
| 210 | std::string port_name = Memory::ReadCString(port_name_address, PortNameMaxLength + 1); | ||
| 211 | if (port_name.size() > PortNameMaxLength) | ||
| 208 | return Kernel::ERR_PORT_NAME_TOO_LONG; | 212 | return Kernel::ERR_PORT_NAME_TOO_LONG; |
| 209 | 213 | ||
| 210 | LOG_TRACE(Kernel_SVC, "called port_name=%s", port_name); | 214 | LOG_TRACE(Kernel_SVC, "called port_name=%s", port_name.c_str()); |
| 211 | 215 | ||
| 212 | auto it = Service::g_kernel_named_ports.find(port_name); | 216 | auto it = Service::g_kernel_named_ports.find(port_name); |
| 213 | if (it == Service::g_kernel_named_ports.end()) { | 217 | if (it == Service::g_kernel_named_ports.end()) { |
| 214 | LOG_WARNING(Kernel_SVC, "tried to connect to unknown port: %s", port_name); | 218 | LOG_WARNING(Kernel_SVC, "tried to connect to unknown port: %s", port_name.c_str()); |
| 215 | return Kernel::ERR_NOT_FOUND; | 219 | return Kernel::ERR_NOT_FOUND; |
| 216 | } | 220 | } |
| 217 | 221 | ||