Replace Genode::strncpy by Genode::copy_cstring

- Since Genode::strncpy is not 100% compatible with the POSIX
  strncpy function, better use a distinct name.

- Remove bogus return value from the function, easing the potential
  enforcement of mandatory return-value checks later.

Fixes #3752
This commit is contained in:
Norman Feske
2020-05-11 16:10:27 +02:00
committed by Christian Helmuth
parent 0f27d139bd
commit b078224753
64 changed files with 114 additions and 117 deletions

View File

@ -65,7 +65,7 @@ class Vfs::Tar_file_system : public File_system
* large enough to host an additional zero.
*/
char buf[sizeof(field) + 1];
strncpy(buf, field, sizeof(buf));
copy_cstring(buf, field, sizeof(buf));
unsigned long value = 0;
Genode::ascii_to_unsigned(buf, value, 8);
@ -394,7 +394,7 @@ class Vfs::Tar_file_system : public File_system
* GNU tar does not null terminate names of length 100
*/
else {
strncpy(path_element, record->name(), 101);
copy_cstring(path_element, record->name(), 101);
current_path.import(path_element);
}
@ -437,14 +437,14 @@ class Vfs::Tar_file_system : public File_system
*/
Genode::size_t name_size = strlen(path_element) + 1;
char *name = (char*)_alloc.alloc(name_size);
strncpy(name, path_element, name_size);
copy_cstring(name, path_element, name_size);
child_node = new (_alloc) Node(name, record);
} else {
/* create a directory node without record */
Genode::size_t name_size = strlen(path_element) + 1;
char *name = (char*)_alloc.alloc(name_size);
strncpy(name, path_element, name_size);
copy_cstring(name, path_element, name_size);
child_node = new (_alloc) Node(name, 0);
}
parent_node->insert(child_node);
@ -510,7 +510,7 @@ class Vfs::Tar_file_system : public File_system
Node *node = root_node.lookup(path);
if (!node)
return 0;
strncpy(key, path, sizeof(key));
copy_cstring(key, path, sizeof(key));
cached_num_dirent = node->num_dirent();
valid = true;
}