Commit graph

56202 commits

Author SHA1 Message Date
Tim Ledbetter
75731f9c50 LibGfx/ILBM: Avoid buffer overruns when decompressing data 2023-11-08 09:36:01 +01:00
Tim Ledbetter
ae6c39e501 LibGfx/ILBM: Ensure decompressed body chunk data is the correct length 2023-11-08 09:36:01 +01:00
Tim Ledbetter
39f7f1e84c Tests: Use more representative test cases for ILBM regression tests
Previously, the regression tests for OSS-Fuzz issues 62033 and 63296
used test case files directly from OSS-Fuzz. These files are invalid
in multiple ways because they have been generated by a fuzzer. This
commit replaces these files with ones that only expose the issue being
tested.
2023-11-08 09:36:01 +01:00
Sam Atkins
21f2f09df4 LibGfx: Remove bit casting in OpenType CBDT table after construction 2023-11-08 09:34:09 +01:00
Sam Atkins
4e944e676b LibGfx: Use to_underlying() to compare ValueFormat enum values
This means we no longer do a bitwise and of a u16 and i16, which feels a
little sketchy.
2023-11-08 09:34:09 +01:00
Sam Atkins
74e5fff77a LibGfx: Reduce bit casting in OpenType GPOS table after construction
Read the basic lists as spans, and use those when looking for kerning.

Kerning lookup still does bit-casting for now. As for CBLC, the data is
a bit complicated.
2023-11-08 09:34:09 +01:00
Sam Atkins
2a4d7a193e LibGfx: Define and use OpenType data types for struct definitions
A few closely-related changes:
- Move our definitions of the OpenType spec's "data types" into their
  own header file.
- Add definitions for the integer types there too, for completeness.
  (Plus Uint16 matches the spec term, and is less verbose than
  BigEndian<u16>.)
- Include Traits for the non-BigEndian types so that we can read them
  from Streams. (BigEndian<integer-type> already has this.)
- Use the integer types in our struct definitions.

As a bonus, this fixes a bug in Hmtx, which read the left-side bearings
as i16 instead of BigEndian<i16>.
2023-11-08 09:34:09 +01:00
Sam Atkins
a28f035d76 LibGfx: Reduce bit casting in OpenType CBLC table after construction
The subtables are still read at use-time for now. I'm sure we could
build some kind of wrapper structures for them though.
2023-11-08 09:34:09 +01:00
Sam Atkins
3c7d654182 LibGfx: Remove bit casting in OpenType Kern table after construction
Do more checks at load time, including categorizing the subtables and
producing our own directory of them.

The format for Kern is a little complicated, so use a Stream instead of
manual offsets.
2023-11-08 09:34:09 +01:00
Sam Atkins
1519290989 AK: Cast pointer in FixedMemoryStream::read_in_place(count)
I didn't notice this before because I only ever called it with u8. Oops!
2023-11-08 09:34:09 +01:00
Sam Atkins
89b35c6dc8 LibGfx: Remove bit casting in OpenType Name table after construction
Store the name records as a span, and a separate bytes span for the
string data.
2023-11-08 09:34:09 +01:00
Sam Atkins
fe2e1a0282 LibGfx: Remove bit casting in OpenType OS2 table after construction 2023-11-08 09:34:09 +01:00
Sam Atkins
d4e1305413 LibGfx: Make OpenType versioned tables more consistent
Maxp had the shared fields duplicated, and OS2 embedded each version's
struct in the next. Instead, let's use inheritance to avoid duplicating
shared fields while still allowing them to be directly accessed.

While I'm at it, rename the Maxp and GPOS table structs to just be
VersionX_Y, because they're not ambiguous with anything else.

LibGfx: Rename GPOSHeader to HeaderVersion1_0

Because there's a version 1.1 as well, which we'll eventually want to
support.
2023-11-08 09:34:09 +01:00
Sam Atkins
75376d6834 LibGfx: Remove bit casting in OpenType Hmtx table after construction
Store the variable-length data in Spans instead.
2023-11-08 09:34:09 +01:00
Sam Atkins
cef4d4821b LibGfx: Remove bit casting in OpenType Maxp table after construction
Store references to both versions of the struct in a Variant, and reject
versions we don't support.
2023-11-08 09:34:09 +01:00
Sam Atkins
e4b3ee09e2 LibGfx: Remove bit casting in OpenType Hhea table after construction 2023-11-08 09:34:09 +01:00
Sam Atkins
dcbe302f83 LibGfx: Remove bit casting in OpenType Head table after construction 2023-11-08 09:34:09 +01:00
Sam Atkins
72483673d2 LibGfx: Use ErrorOr to report failure to load OpenFont tables 2023-11-08 09:34:09 +01:00
Sam Atkins
1ab03ff963 LibGfx: Read OpenType table directory using structs and streams 2023-11-08 09:34:09 +01:00
Sam Atkins
5455ecf650 LibGfx: Remove OpenType::Font::m_buffer
At first glance this looks like it holds the memory that the various
slices point into... but it actually doesn't own that memory. Nobody
uses m_buffer, so it serves no purpose.
2023-11-08 09:34:09 +01:00
Sam Atkins
984a2c314b LibGfx: Read OpenType TTCHeaderV1 as a struct
Also check that the requested font index actually exists in the font
collection.
2023-11-08 09:34:09 +01:00
Sam Atkins
1a6da4fbf2 LibGfx: Mark OpenType file data structs as packed, and assert sizes
Some of these are odd sizes. We managed not to insert padding because
BigEndian is itself marked as packed, but let's be explicit instead of
relying on that. :^)
2023-11-08 09:34:09 +01:00
Sam Atkins
dfa79ba6d8 LibGfx: Move implementation code for Tables.h into Tables.cpp 2023-11-08 09:34:09 +01:00
Romain Chardiny
61ac554a34 Kernel/Net: Implement TCP_NODELAY 2023-11-08 09:31:54 +01:00
Sergey Bugaev
38a368c8f6 WebContent: Fix checking for accelerated graphics
What matters here is whether or not we can use LibAccelGfx and OpenGL,
not whether the kernel is Linux.
2023-11-08 09:29:59 +01:00
Sergey Bugaev
21b946791e LibJS: Link with libatomic on i*86
Basically, this would be needed on any platform where the compiler
cannot tell at compile time whether or not some atomic size is
lock-free.
2023-11-08 09:29:59 +01:00
Sergey Bugaev
9c6c2284d9 LibJS: Fix build error when some atomics are not lock-free
Normally, we want to avoid accidentally using such atomics, since
they're much slower. In this case however, we're just implementing
another atomics API, it is then up to the JavaScript code to avoid
using the slow atomics.
2023-11-08 09:29:59 +01:00
Lucas CHOLLET
81794df280 LibGfx/TIFF: Add support for images with PackBits compression 2023-11-08 09:28:36 +01:00
Lucas CHOLLET
ed8d82f3de Tests/LibGfx: Move the tiff image to its own folder 2023-11-08 09:28:36 +01:00
Lucas CHOLLET
472a886dfc LibGfx/TIFF: Refactor the decoding loop
This is done to ease the introduction of the support of other
compressions.
2023-11-08 09:28:36 +01:00
Timothy Flynn
bf3fce1766 LibJS: Add Date.parse formats for the output of Date.prototype.to*String
We currently cannot parse the output of `toString` and `toUTCString`.
While the spec does not require such support, test262 expects it, and
all major engines support it.
2023-11-08 09:28:17 +01:00
Timothy Flynn
9d3f942d43 LibJS: Display example Date strings inline with their format strings
The current comment style feels a bit awkward to read.
2023-11-08 09:28:17 +01:00
Timothy Flynn
99233776e6 test-js: Add a test helper to override the current time zone 2023-11-08 09:28:17 +01:00
Timothy Flynn
ee7ab5d053 LibCore: Support wildcard-skipping characters in Core::DateTime::parse
For example, LibJS will need to parse date strings of the form:

    Wed Dec 31 1969 19:00:00 GMT-0500 (Eastern Standard Time)

This string contains both the time zone offset (-05:00) and a display
name for the time zone (Eastern Standard Time). Because we will already
handle time zone adjustments when we handle the offsets, we will want to
just skip the time zone name. This patch will let us use a format string
of the form "GMT%z (%+)" to do so.
2023-11-08 09:28:17 +01:00
Timothy Flynn
350fdf1e43 LibCore+LibTimeZone: Support time zone names in Core::DateTime::parse
LibCore currently cannot depend on LibTimeZone directly. All build-time
code generators depend on LibCore, so there'd be a circular dependency:
LibCore -> LibTimeZone -> GenerateTZData -> LibCore.

So to support parsing time zone names and applying their offsets, add a
couple of weakly-defined helper functions. These work similar to the way
AK::String declares some methods that LibUnicode defines. Any user who
wants to parse time zone names (from outside of LibCore itself) can link
against LibTimeZone to receive full support.
2023-11-08 09:28:17 +01:00
Timothy Flynn
fd0075083a LibCore: Change Core::DateTime::parse to accept a StringView
No reason to force an allocation here, as we do not require a NUL-
terminated string.
2023-11-08 09:28:17 +01:00
Timothy Flynn
6655de189f LibCore: Add a Core::System wrapper around unsetenv 2023-11-08 09:28:17 +01:00
Timothy Flynn
2437064820 AK: Define compound subtraction operator for UnixDateTime 2023-11-08 09:28:17 +01:00
Tim Ledbetter
b3d5f9748a LibVideo/VP9: Ensure range decoder size is within expected range 2023-11-08 09:13:59 +01:00
Timothy Flynn
fefbbff0a5 LibEDID: Replace the HTML-based PNP ID parser with a CSV-based parser
The PNP ID file is now a CSV file. Update the generator to handle the
new format.
2023-11-08 08:19:04 +01:00
Timothy Flynn
a02e0afa41 LibEDID: Replace a few DeprecatedString::formatted with String::number
And remove one that was for unused data.
2023-11-08 08:19:04 +01:00
Timothy Flynn
936e97b066 LibEDID: Format PNP ID data a little more cleanly
Namely, do not append unnecessary new lines between PNP ID entries. This
just makes the generated code a bit easier to look through.
2023-11-08 08:19:04 +01:00
Sam Atkins
763b08c23f LibWeb: Remove now-unused CSS::PositionValue type and associated parsing
All the users now use PositionStyleValue instead.
2023-11-07 22:00:24 +00:00
Sam Atkins
7bcabbb325 LibWeb: Store ConicGradientStyleValue's position as PositionStyleValue 2023-11-07 22:00:24 +00:00
Sam Atkins
5cf85d30aa LibWeb: Store RadialGradientStyleValue's position as PositionStyleValue 2023-11-07 22:00:24 +00:00
Sam Atkins
2ae53bc5eb LibWeb: Add some helpers to PositionStyleValue
Both of these are needed by the gradient style values.
2023-11-07 22:00:24 +00:00
Sam Atkins
8917378aa7 LibWeb: Adapt parse_position() into parse_position_value()
Having two ways that `<position>` is represented is awkward and
unnecessary. So, let's combine the two paths together. This first step
copies and modifies the `parse_position()` code to produce a
`PositionStyleValue`.

Apart from returning a StyleValue, this also makes use of automatic enum
parsing instead of manually comparing identifier strings.
2023-11-07 22:00:24 +00:00
Sam Atkins
4ad58f0204 LibWeb: Store PositionStyleValue's edges as EdgeStyleValues
They can't be anything else, so this will make working with them easier.
2023-11-07 22:00:24 +00:00
Sam Atkins
875661a584 LibWeb: Remove unnecessary double->float->double round trip 2023-11-07 22:00:24 +00:00
Sam Atkins
88dc5886eb LibWeb: Use generated to_string() function for EdgeStyleValue edge 2023-11-07 22:00:24 +00:00