From 48e07d7dff2a015a1455dabd6cc7d18392615236 Mon Sep 17 00:00:00 2001 From: Sebastian Sumpf Date: Tue, 9 Oct 2018 13:56:38 +0200 Subject: [PATCH] vfs: support files names of with exactly 100 characters GNU tar does not null terminate or create a long name for file names of exactly 100 characters. issue #3060 --- repos/os/src/lib/vfs/tar_file_system.h | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/repos/os/src/lib/vfs/tar_file_system.h b/repos/os/src/lib/vfs/tar_file_system.h index 96abee536..775e2787b 100644 --- a/repos/os/src/lib/vfs/tar_file_system.h +++ b/repos/os/src/lib/vfs/tar_file_system.h @@ -117,8 +117,9 @@ class Vfs::Tar_file_system : public File_system unsigned type() const { return _long_name() ? _next()->type() : _read(_type); } void *data() const { return _long_name() ? _next()->data() : (void *)_data_begin(); } - char const *name() const { return _long_name() ? _data_begin() : _name; } - char const *linked_name() const { return _long_name() ? _data_begin() : _linked_name; } + char const *name() const { return _long_name() ? _data_begin() : _name; } + unsigned max_name_len() const { return _long_name() ? MAX_PATH_LEN : 100; } + char const *linked_name() const { return _long_name() ? _data_begin() : _linked_name; } file_size storage_size() { @@ -355,10 +356,21 @@ class Vfs::Tar_file_system : public File_system void operator()(Record const *record) { - Absolute_path current_path(record->name()); + Absolute_path current_path; char path_element[MAX_PATH_LEN]; + if (record->max_name_len() > 100 || record->name()[99] == 0) + current_path.import(record->name()); + + /* + * GNU tar does not null terminate names of length 100 + */ + else { + strncpy(path_element, record->name(), 101); + current_path.import(path_element); + } + Path_element_token t(current_path.base()); Node *parent_node = &_root_node;