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
This commit is contained in:
Sebastian Sumpf 2018-10-09 13:56:38 +02:00 committed by Christian Helmuth
parent 2d17af9f28
commit 48e07d7dff

View File

@ -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;