mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:08:12 +00:00
Kernel: Don't include null terminator in sys$readlink() result
POSIX says, "Conforming applications should not assume that the returned contents of the symbolic link are null-terminated." If we do include the null terminator into the returning string, Python believes it to actually be a part of the returned name, and gets unhappy about that later. This suggests other systems Python runs in don't include it, so let's do that too. Also, make our userspace support non-null-terminated realpath().
This commit is contained in:
parent
1dee4d0049
commit
f18d6610d3
3 changed files with 11 additions and 8 deletions
|
@ -1950,10 +1950,10 @@ int Process::sys$readlink(const Syscall::SC_readlink_params* user_params)
|
|||
return -EIO; // FIXME: Get a more detailed error from VFS.
|
||||
|
||||
auto link_target = String::copy(contents);
|
||||
if (link_target.length() + 1 > params.buffer.size)
|
||||
if (link_target.length() > params.buffer.size)
|
||||
return -ENAMETOOLONG;
|
||||
copy_to_user(params.buffer.data, link_target.characters(), link_target.length() + 1);
|
||||
return link_target.length() + 1;
|
||||
copy_to_user(params.buffer.data, link_target.characters(), link_target.length());
|
||||
return link_target.length();
|
||||
}
|
||||
|
||||
int Process::sys$chdir(const char* user_path, size_t path_length)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue