From ee25dcbae344766c20ced472da38f023cead47d7 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Tue, 24 Nov 2015 15:12:47 +0100 Subject: [PATCH] VFS: check path on the symlink node readlink Fixes #1790 --- repos/os/include/vfs/symlink_file_system.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/repos/os/include/vfs/symlink_file_system.h b/repos/os/include/vfs/symlink_file_system.h index 3555daac9..845216b11 100644 --- a/repos/os/include/vfs/symlink_file_system.h +++ b/repos/os/include/vfs/symlink_file_system.h @@ -66,6 +66,8 @@ class Vfs::Symlink_file_system : public File_system file_size buf_size, file_size &out_len) override { + if (!_is_single_file(path)) + return READLINK_ERR_NO_ENTRY; out_len = min(buf_size, file_size(sizeof(_target))); strncpy(buf, _target, out_len); return READLINK_OK; @@ -104,7 +106,7 @@ class Vfs::Symlink_file_system : public File_system char const *leaf_path(char const *path) override { - return path; + return _is_single_file(path) ? path : 0; } Dirent_result dirent(char const *path, file_offset index, Dirent &out) override @@ -112,11 +114,13 @@ class Vfs::Symlink_file_system : public File_system if (!_is_root(path)) return DIRENT_ERR_INVALID_PATH; + out.fileno = 1; if (index == 0) { out.type = DIRENT_TYPE_SYMLINK; strncpy(out.name, _filename, sizeof(out.name)); } else { out.type = DIRENT_TYPE_END; + out.name[0] = '\0'; } return DIRENT_OK;