Commit Graph

66 Commits

Author SHA1 Message Date
Shannon Booth
e2e7c4d574 Everywhere: Use to_number<T> instead of to_{int,uint,float,double}
In a bunch of cases, this actually ends up simplifying the code as
to_number will handle something such as:

```
Optional<I> opt;
if constexpr (IsSigned<I>)
    opt = view.to_int<I>();
else
    opt = view.to_uint<I>();
```

For us.

The main goal here however is to have a single generic number conversion
API between all of the String classes.
2023-12-23 20:41:07 +01:00
Tim Schumacher
a2f60911fe AK: Rename GenericTraits to DefaultTraits
This feels like a more fitting name for something that provides the
default values for Traits.
2023-11-09 10:05:51 -05:00
Tim Ledbetter
9f7cfb1394 LibArchive: Ensure tar extended header length is within expected range 2023-10-03 15:39:20 +02:00
Sam Atkins
8d53442187 LibArchive: Extract logic for calculating ZIP statistics 2023-07-30 22:16:40 +01:00
Caoimhe
b5124bd826 LibArchive: Add helper functions for adding members to a ZipOutputStream 2023-07-08 13:14:50 +01:00
Timothy Flynn
c911781c21 Everywhere: Remove needless trailing semi-colons after functions
This is a new option in clang-format-16.
2023-07-08 10:32:56 +01:00
Romain Chardiny
dc65a2f2b8 unzip: Add option to list files of an archive 2023-06-15 21:01:51 +01:00
Tim Schumacher
26ba195cf6 LibArchive: Read Tar archive headers through read_value 2023-03-13 15:16:20 +00:00
Tim Schumacher
ecd1862859 AK: Rename Stream::write_entire_buffer to Stream::write_until_depleted
No functional changes.
2023-03-13 15:16:20 +00:00
Tim Schumacher
a3f73e7d85 AK: Rename Stream::read_entire_buffer to Stream::read_until_filled
No functional changes.
2023-03-13 15:16:20 +00:00
Tim Schumacher
d5871f5717 AK: Rename Stream::{read,write} to Stream::{read_some,write_some}
Similar to POSIX read, the basic read and write functions of AK::Stream
do not have a lower limit of how much data they read or write (apart
from "none at all").

Rename the functions to "read some [data]" and "write some [data]" (with
"data" being omitted, since everything here is reading and writing data)
to make them sufficiently distinct from the functions that ensure to
use the entire buffer (which should be the go-to function for most
usages).

No functional changes, just a lot of new FIXMEs.
2023-03-13 15:16:20 +00:00
Tim Schumacher
43f98ac6e1 Everywhere: Remove the AK:: qualifier from Stream usages 2023-02-13 00:50:07 +00:00
Tim Schumacher
874c7bba28 LibCore: Remove Stream.h 2023-02-13 00:50:07 +00:00
Ollrogge
0ce1c52577 LibArchive: Add support for modification time and date 2023-02-12 13:13:15 -07:00
Tim Schumacher
8464da1439 AK: Move Stream and SeekableStream from LibCore
`Stream` will be qualified as `AK::Stream` until we remove the
`Core::Stream` namespace. `IODevice` now reuses the `SeekMode` that is
defined by `SeekableStream`, since defining its own would require us to
qualify it with `AK::SeekMode` everywhere.
2023-01-29 19:16:44 -07:00
Tim Schumacher
5f2ea31816 AK: Move Handle from LibCore and name it MaybeOwned
The new name should make it abundantly clear what it does.
2023-01-29 19:16:44 -07:00
Tim Schumacher
1ca62de558 LibCore: Return EBADF on unsupported stream operations 2023-01-19 11:41:56 +01:00
implicitfield
ebcd07ff33 LibArchive: Use read_entire_buffer for reading extended headers
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=53913
2023-01-08 09:54:08 +00:00
implicitfield
28c99e7a1f LibArchive+Utilities: Stop using DeprecatedString
This also slightly improves error propagation in tar, unzip and zip.
2023-01-08 09:54:08 +00:00
Karol Kosek
8238f926fd LibArchive+Utilities: Port ZipOutputStream to Core::Stream 2022-12-27 07:24:07 +03:30
Tim Schumacher
69de709625 LibArchive: Do some error propagation while packing tar files 2022-12-14 15:20:37 +00:00
Tim Schumacher
1ec646ab94 LibArchive: Port TarOutputStream to Core::Stream 2022-12-14 15:20:37 +00:00
Linus Groh
6e19ab2bbc AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
2022-12-06 08:54:33 +01:00
Tim Schumacher
714f0c3dce LibArchive: Implement proper support for Tar file end markers
Previously this was handled implicitly, as our implementation of Tar
would just stop processing input as soon as it found something invalid.
However, since we now error out as soon as something is found to be
wrong, we require proper handling for zero blocks, which aren't actually
fatal.
2022-11-30 08:03:31 +01:00
Tim Schumacher
cb48b9bc30 LibArchive: Pass along errors from Tar header checksum validation 2022-11-30 08:03:31 +01:00
Tim Schumacher
fd3a823a20 LibArchive: Move loading the next tar header into a helper function
This now also validates the first header that is loaded, so we can drop
the corresponding FIXME from `tar`.
2022-11-30 08:03:31 +01:00
Tim Schumacher
cbeaba0c12 LibArchive: Use Core::Stream inside TarInputStream 2022-11-30 08:03:31 +01:00
Tim Schumacher
71d1d9e2b5 LibArchive: Port TarFileStream to Core::Stream 2022-11-30 08:03:31 +01:00
implicitfield
e277185eb1 LibArchive: Do not assert if the provided stream cannot be discarded
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=52498
2022-11-23 11:19:16 +01:00
implicitfield
ee0c9ed87b LibArchive: Simplify error handling 2022-11-23 11:19:16 +01:00
implicitfield
58e9262ff1 LibArchive: Make get_field_as_integral error out on non-octal input
Fixes this bug that was reported by OSS-Fuzz:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=52493
2022-11-13 17:37:26 -07:00
implicitfield
c88d8a21cc LibArchive: Make TarInputStream::advance report errors
Fixes this bug that was reported by OSS-Fuzz:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=52862
2022-11-13 17:37:26 -07:00
Tim Schumacher
ce2f1b845f Everywhere: Mark dependencies of most targets as PRIVATE
Otherwise, we end up propagating those dependencies into targets that
link against that library, which creates unnecessary link-time
dependencies.

Also included are changes to readd now missing dependencies to tools
that actually need them.
2022-11-01 14:49:09 +00:00
Peter Elliott
83e62e8c4f Utilities+LibArchive: Don't follow symlinks 2022-10-31 22:10:22 +00:00
Peter Elliott
612a3324d7 LibArchive: Support writing paths up to 255 characters
The POSIX.1-1988 limit was 100, but with the ustar prefix field it's 255
(kinda).
2022-10-31 22:10:22 +00:00
Peter Elliott
9ae36e2035 LibArchive: Refactor null-termination logic in TarFileHeader
Before this change the behavior was, confusingly:
- never null-terminate if set_field() is passed a StringView.
  - which would also not fail if the StringView is too large.
- require null-termination if set_field() is passed a String.

Not only are both of these wrong, having different behavior for those is
very confusing, and creating a String copy to force a type checker to
cause a string to be null-terminated is extremely weird.

The new behavior is to always null-terminate when possible, never
null-terminate if the last byte is used, and always verify that the
string will fit.
2022-10-31 22:10:22 +00:00
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