diff options
author | Sergey Bugaev <bugaevc@serenityos.org> | 2020-04-14 18:39:56 +0300 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-04-14 18:40:24 +0200 |
commit | f18d6610d364bea6f96d954a74939371c42d2de3 (patch) | |
tree | b198c9ca3c6767881d4d0c70303ac3e3448ef87a /Applications/FileManager | |
parent | 1dee4d004915245193ccbe848b783be0208fd3e7 (diff) | |
download | serenity-f18d6610d364bea6f96d954a74939371c42d2de3.zip |
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().
Diffstat (limited to 'Applications/FileManager')
-rw-r--r-- | Applications/FileManager/PropertiesDialog.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Applications/FileManager/PropertiesDialog.cpp b/Applications/FileManager/PropertiesDialog.cpp index 97866016b0..10b8950914 100644 --- a/Applications/FileManager/PropertiesDialog.cpp +++ b/Applications/FileManager/PropertiesDialog.cpp @@ -108,10 +108,11 @@ PropertiesDialog::PropertiesDialog(GUI::FileSystemModel& model, String path, boo if (S_ISLNK(m_mode)) { char link_destination[PATH_MAX]; - if (readlink(path.characters(), link_destination, sizeof(link_destination)) < 0) { + ssize_t len = readlink(path.characters(), link_destination, sizeof(link_destination)); + if (len < 0) { perror("readlink"); } else { - properties.append({ "Link target:", link_destination }); + properties.append({ "Link target:", String(link_destination, len) }); } } |