Commit Graph

30 Commits

Author SHA1 Message Date
sin-ack
3f3f45580a Everywhere: Add sv suffix to strings relying on StringView(char const*)
Each of these strings would previously rely on StringView's char const*
constructor overload, which would call __builtin_strlen on the string.
Since we now have operator ""sv, we can replace these with much simpler
versions. This opens the door to being able to remove
StringView(char const*).

No functional changes.
2022-07-12 23:11:35 +02:00
sin-ack
c70f45ff44 Everywhere: Explicitly specify the size in StringView constructors
This commit moves the length calculations out to be directly on the
StringView users. This is an important step towards the goal of removing
StringView(char const*), as it moves the responsibility of calculating
the size of the string to the user of the StringView (which will prevent
naive uses causing OOB access).
2022-07-12 23:11:35 +02:00
Andrew Kaster
c774790975 LibArchive: Guard against major() and minor() macros from old glibc
glibc before 2.28 defines major() and minor() macros from sys/types.h.

This triggers a Lagom warning for old distros that use versions older
than that, such as Ubuntu 18.04. This fixes a break in the
compiler-explorer Lagom build, which is based off 18.04 docker
containers.
2022-07-05 01:27:37 +02:00
Tim Schumacher
87da3e0004 tar: Implement support for GNU longname headers 2022-06-06 20:12:30 +01:00
Tim Schumacher
acc9be9f7d LibArchive: Use named members for ZIP general purpose flags
This fixes the faulty bit check that misclassified ZIPs as having
data descriptors.
2022-05-12 22:58:14 +02:00
Idan Horowitz
118d381091 LibArchive: Stop null-terminating StringView tar file header fields
Since 8209c2b570 was added the requires
check for copy_characters_to_buffer matched StringViews as well, which
caused unexpected null bytes to be inserted for non null-terminated
fields.
2022-04-13 19:51:57 +02:00
Idan Horowitz
086969277e Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
Lenny Maiorani
be360db223 Libraries: Change enums to enum classes in LibArchive 2022-03-18 19:59:43 +01:00
Daniel Bertalan
a285e651f1 LibArchive: Accept space characters as terminators of tar numeric fields
POSIX specifies that each numeric field is terminated with one or more
space or NUL characters.
2022-03-08 23:30:47 +01:00
Tim Schumacher
f6e86915f5 LibArchive: Implement a basic parser for tar extended headers 2022-03-05 13:17:13 +01:00
Tim Schumacher
e0dba2b81b LibArchive: Add TarFileHeader::content_is_like_extended_header() 2022-03-05 13:17:13 +01:00
Lenny Maiorani
c0735b047e LibArchive: Use designated initializers
Benefits:
- Braced-initialization prevents unknown narrowing conversions.
- Using designated initializers will result in a compiler error when a
  member is skipped or forgotten.
2022-02-18 23:54:14 +02:00
Lenny Maiorani
484c0edafc LibArchive: Refactor zip header handling
The directory headers have some common code for reading.
2022-02-18 23:54:14 +02:00
Lenny Maiorani
deba345ca7 LibArchive: Default initialize member variables
Problem:
- `memset` is used to initialize data instead of using default
  initialization.

Solution:
- Default initialize all member variables.
- Eliminate use of `memset` in favor of C++ braced initialization.
2022-02-15 23:00:19 +02:00
Lenny Maiorani
847efd8aca LibArchive: Use constexpr variables where possible 2022-02-15 23:00:19 +02:00
Lenny Maiorani
583e197897 LibArchive: Refactor Tar to make DRY (Don't Repeat Yourself)
Problem:
- The getters and setters duplicate code for conversions.
- Getters are returning `const StringView` rather than non-`const`.

Solution:
- Factor out common code to helper functions.
- Return `StringView` as non-`const`.
2022-02-15 23:00:19 +02:00
Tim Schumacher
acf3154483 LibArchive: Limit all Tar header fields to their buffer length 2021-11-24 19:09:00 +02:00
Andreas Kling
80d4e830a0 Everywhere: Pass AK::ReadonlyBytes by value 2021-11-11 01:27:46 +01:00
Peter Elliott
33d7fdca28 Everywhere: Use my cool new @serenityos.org email address 2021-09-01 11:37:25 +04:30
Jean-Baptiste Boric
d0eb376520 LibArchive: Move method implementations away from header 2021-05-17 18:14:05 +01:00
Andreas Kling
7ae7170d61 Everywhere: "file name" => "filename" 2021-04-29 22:16:18 +02:00
Idan Horowitz
1c512a702a AK+Userland: Use idan.horowitz@serenityos.org for my copyright headers 2021-04-22 22:42:38 +02:00
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00
Linus Groh
2b0c361d04 Everywhere: Fix a bunch of typos 2021-04-18 10:30:03 +02:00
Peter Elliott
dcee024fee LibArchive: Support POSIX.1-1988 tar files
These old tar files didn't have magic numbers, so I've also added a checksum
check to TarInputStream::valid()
2021-04-12 14:06:24 +02:00
Idan Horowitz
1ac661515e LibArchive: Bounds check header offsets in Zip Parser
Since the central directory offset in the end of central directory
record and the local file offset in each central directory header
are user-controlled arbitary data, we have to bounds check them
before using them.
2021-03-27 19:44:16 +01:00
Idan Horowitz
4317db7498 LibArchive: Make bounds checks stricter in the Zip parser
We now also check we have enough space in the incoming buffer for the
various signatures and optional (length specified) fields. This helps
prevents a possible heap overflow read.
2021-03-27 16:28:48 +01:00
Idan Horowitz
550ae23e80 LibArchive: Implement ZipOutputStream for zip archive creation
This output stream can be used to create zip archives, and will
be used in the implementation of the zip utility.
2021-03-23 16:09:36 +01:00
Idan Horowitz
caf4bde3a9 LibArchive: Add Zip file parser
This is based on the zip specification on PKWARE's zip specification
(https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT) and will
be used in the unzip utility and eventually in the zip utility.
2021-03-23 16:09:36 +01:00
Idan Horowitz
a809db90dd Libraries: Rename LibTar to LibArchive
This is in preparation for a new implementation of zip archive
extraction and creation.
2021-03-23 16:09:36 +01:00