summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorTim Schumacher <timschumi@gmx.de>2021-11-24 17:33:32 +0100
committerIdan Horowitz <idan.horowitz@gmail.com>2021-11-24 19:09:00 +0200
commitacf31544839adccfc9cd8a102a729bfec7aa5d01 (patch)
tree0d5a5d83bedae6e96901bba17b413867f097481a /Userland/Libraries
parent251f692440c4ffafe0ba10eaf151165e7c9940a4 (diff)
downloadserenity-acf31544839adccfc9cd8a102a729bfec7aa5d01.zip
LibArchive: Limit all Tar header fields to their buffer length
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibArchive/Tar.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/Userland/Libraries/LibArchive/Tar.h b/Userland/Libraries/LibArchive/Tar.h
index 52fd60bbd1..95fb48acfa 100644
--- a/Userland/Libraries/LibArchive/Tar.h
+++ b/Userland/Libraries/LibArchive/Tar.h
@@ -38,7 +38,7 @@ constexpr const char* posix1_tar_version = ""; // POSIX.1-1988 format version
class [[gnu::packed]] TarFileHeader {
public:
- const StringView filename() const { return m_filename; }
+ const StringView filename() const { return StringView(m_filename, min(__builtin_strlen(m_filename), sizeof(m_filename))); }
mode_t mode() const { return get_tar_field(m_mode); }
uid_t uid() const { return get_tar_field(m_uid); }
gid_t gid() const { return get_tar_field(m_gid); }
@@ -48,14 +48,14 @@ public:
unsigned checksum() const { return get_tar_field(m_checksum); }
TarFileType type_flag() const { return TarFileType(m_type_flag); }
const StringView link_name() const { return m_link_name; }
- const StringView magic() const { return StringView(m_magic, min(__builtin_strlen(m_magic), sizeof(m_magic))); } // in some cases this is a null terminated string, in others its not
- const StringView version() const { return StringView(m_version, min(__builtin_strlen(m_version), sizeof(m_version))); } // in some cases this is a null terminated string, in others its not
- const StringView owner_name() const { return m_owner_name; }
- const StringView group_name() const { return m_group_name; }
+ const StringView magic() const { return StringView(m_magic, min(__builtin_strlen(m_magic), sizeof(m_magic))); }
+ const StringView version() const { return StringView(m_version, min(__builtin_strlen(m_version), sizeof(m_version))); }
+ const StringView owner_name() const { return StringView(m_owner_name, min(__builtin_strlen(m_owner_name), sizeof(m_owner_name))); }
+ const StringView group_name() const { return StringView(m_group_name, min(__builtin_strlen(m_group_name), sizeof(m_group_name))); }
int major() const { return get_tar_field(m_major); }
int minor() const { return get_tar_field(m_minor); }
// FIXME: support ustar filename prefix
- const StringView prefix() const { return m_prefix; }
+ const StringView prefix() const { return StringView(m_prefix, min(__builtin_strlen(m_prefix), sizeof(m_prefix))); }
void set_filename(const String& filename) { VERIFY(filename.copy_characters_to_buffer(m_filename, sizeof(m_filename))); }
void set_mode(mode_t mode) { VERIFY(String::formatted("{:o}", mode).copy_characters_to_buffer(m_mode, sizeof(m_mode))); }