diff --git a/Userland/DevTools/UserspaceEmulator/Emulator.cpp b/Userland/DevTools/UserspaceEmulator/Emulator.cpp index db73c53041..c43b47cd0b 100644 --- a/Userland/DevTools/UserspaceEmulator/Emulator.cpp +++ b/Userland/DevTools/UserspaceEmulator/Emulator.cpp @@ -1364,20 +1364,16 @@ int Emulator::virt$realpath(FlatPtr params_addr) Syscall::SC_realpath_params params; mmu().copy_from_vm(¶ms, params_addr, sizeof(params)); - if (params.path.length > PATH_MAX) { - return -ENAMETOOLONG; - } auto path = mmu().copy_buffer_from_vm((FlatPtr)params.path.characters, params.path.length); - char host_buffer[PATH_MAX] = {}; - size_t host_buffer_size = min(sizeof(host_buffer), params.buffer.size); + auto host_buffer = ByteBuffer::create_zeroed(params.buffer.size); Syscall::SC_realpath_params host_params; host_params.path = { (const char*)path.data(), path.size() }; - host_params.buffer = { host_buffer, host_buffer_size }; + host_params.buffer = { (char*)host_buffer.data(), host_buffer.size() }; int rc = syscall(SC_realpath, &host_params); if (rc < 0) return rc; - mmu().copy_to_vm((FlatPtr)params.buffer.data, host_buffer, host_buffer_size); + mmu().copy_to_vm((FlatPtr)params.buffer.data, host_buffer.data(), host_buffer.size()); return rc; } @@ -1759,20 +1755,16 @@ int Emulator::virt$readlink(FlatPtr params_addr) Syscall::SC_readlink_params params; mmu().copy_from_vm(¶ms, params_addr, sizeof(params)); - if (params.path.length > PATH_MAX) { - return -ENAMETOOLONG; - } auto path = mmu().copy_buffer_from_vm((FlatPtr)params.path.characters, params.path.length); - char host_buffer[PATH_MAX] = {}; - size_t host_buffer_size = min(sizeof(host_buffer), params.buffer.size); + auto host_buffer = ByteBuffer::create_zeroed(params.buffer.size); Syscall::SC_readlink_params host_params; host_params.path = { (const char*)path.data(), path.size() }; - host_params.buffer = { host_buffer, host_buffer_size }; + host_params.buffer = { (char*)host_buffer.data(), host_buffer.size() }; int rc = syscall(SC_readlink, &host_params); if (rc < 0) return rc; - mmu().copy_to_vm((FlatPtr)params.buffer.data, host_buffer, host_buffer_size); + mmu().copy_to_vm((FlatPtr)params.buffer.data, host_buffer.data(), host_buffer.size()); return rc; }