Commit Graph

59947 Commits

Author SHA1 Message Date
Liav A.
a90e876667 Userland/mount: Fix srcobfuscate => srchidden when printing mounts
Fixes 0734de9f9a.
By mistake, I forgot to change this instance to "srchidden", so let's
fix this.
2024-03-14 18:18:39 -06:00
Nico Weber
df9dd8ec69 LibGfx/JBIG2: Add arithmetic coding decoder
I think the context normally changes for every bit. But this here
is enough to correctly decode the test bitstream in Annex H.2 in
the spec, which seems like a good checkpoint.

The internals of the decoder use spec naming, to make the code
look virtually identical to what's in the spec. (Even so, I managed
to put in several typos that took a while to track down.)
2024-03-14 18:18:15 -06:00
Andrew Kaster
c4be9318a2 Tests: Only use a 256-bit RSA key in SubtleCrypto generateKey test
Until we get a better performing RSA keygen algorithm, this test times
out occasionally in CI with a 512-bit key.
2024-03-14 17:57:37 -06:00
Andrew Kaster
1521a60a67 LibWeb: Support SubtleCrypto.exportKey for RSA-OAEP in JsonWebKey format 2024-03-14 17:57:37 -06:00
Andrew Kaster
2599142214 LibWeb: Export UnsignedBigInts into Uint8Arrays without losing bytes
The behavior of Crypto::UnsignedBigInt::export_data unexpectedly
does not actually remove leading zero bytes when the corresponding
parameter is passed. The caller must manually adjust for the location
of the zero bytes.
2024-03-14 17:57:37 -06:00
Andrew Kaster
0a3d27c41d LibWeb: Make SubtleCrypto AlgorithmParams classes virtual
This allows us to properly destroy the child classes through a pointer
to the base class, avoiding ASAN/UBSAN errors.
2024-03-14 17:57:37 -06:00
Andrew Kaster
1d70306c41 Meta: Handle output directories for multi-config CMake generators
For Ninja Multi-Config, Xcode and Visual Studio, the way we set up our
output directories would result in exectuables that can't run from the
build directory. Add the same sauce that we added to Jakt to insert
``$<CONFIG>`` where appropriate.
2024-03-14 17:05:05 -06:00
Lucas CHOLLET
06665cba9c LibGfx/TIFF: Reject images with an incoherent number of BitsPerSample
Fixes oss-fuzz issue 66588:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=66588
2024-03-14 11:12:31 -04:00
Nico Weber
d15785cccc MacPDF: Add "Show Images" debug menu entry
PDFViewer has this, and it's useful for PDFs that have the same
text both as a scanned bitmap in the background as well as using
vector text in the foreground.

xib changes: Added a new menu entry connected to `toggleShowImages:`,
and also toggled the initial state of two menu entries. (The latter
part has no effect when the program runs since we dynamically update
this state, but it makes the menu entries show their initial state
in Xcode's menu editor.)
2024-03-14 10:59:29 -04:00
Nico Weber
98729c97f4 LibGfx/JBIG2: Simplify and restrict adaptive template pixel reading
EXTTEMPLATE=1 was added later and doesn't seem to be used much in
practice -- it doesn't appear in no simple generic regions in any PDF
I tested so far at least. Since the spec contradicts itself on what
to do with these as far as I can tell, error out on them for now and
then add support once we find actual files using this, so that we can
check our implementation actually works.

Deduplicate the data reading for the different cases, and
zero-initialize all adaptive template pixels to zero to make that
possible.

Other than prohibiting EXTTEMPLATE=1, no behavior change.
2024-03-14 10:57:57 -04:00
Nico Weber
596b06333f LibGfx/JBIG2: Add a dbgln_if(JBIG2_DEBUG) for non-MMR generic regions 2024-03-14 10:57:57 -04:00
Nico Weber
77850f06dc Tests: Remove logspam from TestPainter 2024-03-14 10:56:13 -04:00
Jan200101
466f1f5bf3 Ports: Update lite-xl to 2.1.3 2024-03-14 15:42:58 +01:00
Andreas Kling
0c76c7ee36 LibWeb: Make Element::is_document_element() slightly nicer
By following the spec more closely, we can actually make this function
a bit more efficient (by comparing the parent against the document
instead of looking for the first element child of the document).
2024-03-14 12:42:08 +01:00
Andreas Kling
bbf67faa95 LibWeb: Add CSS rule buckets for pseudo elements, and for :root
If a selector must match a pseudo element, or must match the root
element, we now cache that information in the MatchingRule struct.
We also introduce separate buckets for these rules, so we can avoid
running them altogether if the current element can't possibly match.

This cuts the number of selectors evaluated by 32% when loading our
GitHub repo page https://github.com/SerenityOS/serenity
2024-03-14 12:42:08 +01:00
Andreas Kling
c6e37d0c44 LibWeb: Give Vector<MatchingRule> some inline capacity in StyleComputer
We frequently end up matching hundreds or even thousands of rules. By
giving this vector some inline capacity, we avoid a lot of the
repetitive churn from dynamically growing it all the way from 0
capacity.
2024-03-14 12:42:08 +01:00
Andreas Kling
d125a76f85 AK: Make FlyString-to-FlyString comparison inline & trivial
This should never boil down to more than a machine word comparison.
2024-03-14 12:42:08 +01:00
Timothy Flynn
bc23c5b9fe LibWeb: Append the bytes of File objects in submitted form data
This is required to upload files to GitHub. Unfortunately, this is not
currently testable with our test infrastructure. This path is only hit
from HTTP/S uploads, whereas all of our tests are limited to file://.
2024-03-14 10:10:33 +01:00
Timothy Flynn
c0d18e976e LibWeb: Use string literals as format strings during form serialization
Passing a StringView bypasses compile-time format string validation.
2024-03-14 10:10:33 +01:00
Timothy Flynn
bb38cc1010 LibWeb: Do not blindly create File objects when adding FormData entries
We were unconditionally creating new File objects for all Blob-type
values passed to `FormData.append`. We should only do so if the value is
not already a File object (or if the `filename` attribute is present).

We must also carry MIME type information forward from the underlying
Blob object.
2024-03-14 10:10:33 +01:00
Timothy Flynn
f55471333b LibWeb: Set the MIME type when creating an <input> element's File list
We were passing the MIME type to the underlying Blob, but the factory
for creating a File only checks an explicit options structure.
2024-03-14 10:10:33 +01:00
Timothy Flynn
0cc8698a62 LibWeb: Reverse check for whether a FilesList index is supported
This fixes for..of iteration of a FilesList object.
2024-03-14 10:10:33 +01:00
Timothy Flynn
c2ef506b4a LibWeb: Add an empty DataTransfer IDL implementation
This does not implement any of the IDL methods, but GitHub requires the
interface exists to upload files via an <input type="file"> element.
Their JS handles uploads via this element and via drag-and-drop in one
function, and check if the uploaded file is `instanceof DataTransfer` to
decide how to handle it.
2024-03-14 10:10:33 +01:00
Timothy Flynn
7681772b9f LibWeb: Log failed Fetch responses when WEB_FETCH_DEBUG is enabled
We do the same for successful responses. Very useful for debugging
issues on live websites.
2024-03-14 10:10:33 +01:00
mrkubax10
eb0d56a4ed Kernel/Net: Implement support for RTL8168C
Please be aware that I only have NIC with chip version 6 so
this is the only one that I have tested. Rest was implemented
via looking at Linux rtl8169 driver. Also thanks to IdanHo
for some initial work.
2024-03-13 22:09:54 -06:00
Cubic Love
15d6b3017a Snake: Set Snake as default skin
Set 'Snake' as the default skin for its aesthetic appeal and color
harmony with the game's icon.
2024-03-13 22:05:31 -06:00
Nico Weber
7740aeca29 LibGfx/JBIG2: Fix size bound in scan_for_immediate_generic_region_size()
The memmem() call passes `data.size() - 19 - sizeof(u32)` for big_len,
(18 prefix bytes skipped, the flag byte, and the trailing u32), so the
buffer needs to be at least that large.

Should fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=67332
2024-03-13 22:01:06 -06:00
Liav A
ec6e7077fe Tests/Kernel: Add tests for verifying proper loop device support 2024-03-13 15:33:47 -06:00
Liav A
0734de9f9a Kernel+Userland: Add mount MS_SRCHIDDEN option
Either we mount from a loop device or other source, the user might want
to obfuscate the given source for security reasons, so this option will
ensure this will happen.
If passed during a mount, the source will be hidden when reading from
the /sys/kernel/df node.
2024-03-13 15:33:47 -06:00
Liav A
0739b5df11 Utilities/mount: Automatically mount regular files with loop devices
Check if the source fd is not a block device file using the fstat
syscall and if that's the case, try to mount the file using a temporary
loop device.
2024-03-13 15:33:47 -06:00
Liav A
e14c571916 Tests/Kernel: Add test for /dev/loop directory structure 2024-03-13 15:33:47 -06:00
Liav A
d14a0a454a SystemServer: Mount DevLoopFS on /dev/loop
Let's use the new DevLoopFS filesystem on /dev/loop to see the loop
devices immediately as they're created or deleted.
2024-03-13 15:33:47 -06:00
Liav A
0d2e4a7e67 Kernel/FileSystem: Add the DevLoopFS filesystem
Similarly to DevPtsFS, this filesystem is about exposing loop device
nodes easily in /dev/loop, so userspace doesn't need to do anything in
order to use new devices immediately.
2024-03-13 15:33:47 -06:00
Liav A
11ead5c84f Kernel: Get RefPtr<Device> from the DeviceManagement::get_device method
Instead of returning a raw pointer, which could be technically invalid
when using it in the caller function, we return a valid RefPtr of such
device.

This ensures that the code in DevPtsFS is now safe from a rare race
condition in which the SlavePTY device is gone but we still have a
pointer to it.
2024-03-13 15:33:47 -06:00
Liav A
5dcf03ad9a Kernel/Devices: Introduce the LoopDevice device
This device is a block device that allows a user to effectively treat an
Inode as a block device.

The static construction method is given an OpenFileDescription reference
but validates that:
- The description has a valid custody (so it's not some arbitrary file).
  Failing this requirement will yield EINVAL.
- The description custody points to an Inode which is a regular file, as
  we only support (seekable) regular files. Failing this requirement
  will yield ENOTSUP.

LoopDevice can be used to mount a regular file on the filesystem like
other supported types of (physical) block devices.
2024-03-13 15:33:47 -06:00
Andrew Kaster
a9d240c647 LibWeb: Implement SubtleCrypto.generateKey for RSA-OAEP
This patch implements and tests window.crypto.sublte.generateKey with
an RSA-OAEP algorithm. In order for the types to be happy, the
KeyAlgorithms objects are moved to their own .h/.cpp pair, and the new
KeyAlgorithms for RSA are added there.
2024-03-13 15:31:00 -06:00
Andrew Kaster
008c89edde LibCrypto: Add observers for the *byte* length of UnsignedBigInteger
When calling the export_data method, it's a bit of a hassle to remember
that the caller's buffer needs to be the length() * Word.
2024-03-13 15:31:00 -06:00
Andrew Kaster
139ff3552c LibCrypto: Allow callers to pass exponent to RSA::generate_key_pair 2024-03-13 15:31:00 -06:00
Andrew Kaster
0b4858e589 LibWeb: Implement SubtleCrypto.generateKey skeleton
We don't have any algorithms defined that actually support generateKey,
but now all the scaffolding is there.
2024-03-13 15:31:00 -06:00
Andrew Kaster
810be6af07 LibWeb: Add CryptoKeyPair object for use in upcoming SubtleCrypto APIs 2024-03-13 15:31:00 -06:00
Andrew Kaster
0a6f195a71 LibWeb: Implement usages property for CryptoKey
And set it from the only place we currently create a CryptoKey, in
importKey.
2024-03-13 15:31:00 -06:00
Andrew Kaster
2d59d6c98c LibWeb: Refactor SubtleCrypto to allow adding more algorithms easier
This patch throws away some of the spec suggestions for how to implement
the normalize_algorithm AO and uses a new pattern that we can actually
extend in our C++.

Also update CryptoKey to store the key data.
2024-03-13 15:31:00 -06:00
Timothy Flynn
644e764620 RequestServer: Use Core::System::pipe2 for creating the request FDs
This causes a behavior change in which the read FD is now non-blocking.
This is intentional, as this change avoids a deadlock between RS and
WebContent, where WC could block while reading from the request FD,
while RS is blocked sending a message to WC.
2024-03-13 12:52:07 -04:00
Timothy Flynn
a973fe13cb LibCore: Use Core::System::pipe2 for creating the event loops waking FDs 2024-03-13 12:52:07 -04:00
Timothy Flynn
40beebca71 LibCore: Apply the flags provided to System::pipe2 on all systems
We currently drop the flags on the floor for systems that do not have a
pipe2 syscall. Instead, use fcntl to set the flags.
2024-03-13 12:52:07 -04:00
Timothy Flynn
dd271adcf5 RequestServer: Do not defer establishing a TCP/TLS connection
The underlying issue here isn't quite understood yet, but for some
reason, when we defer this connection, we ultimately end up blocking
indefinitely on macOS when a subsequent StartRequest message tries to
send its request FD over IPC. We should continue investigating that
issue, but for now, this lets us use RequestServer more reliably on
macOS.
2024-03-13 12:52:07 -04:00
Timothy Flynn
d5ce45b016 Meta: Port recent changes to the GN build
163b6bb401
3b4230e0b0
2024-03-13 12:52:07 -04:00
Bastiaan van der Plaat
16fdb005f0 Ladybird/Qt: Allow CR inside of elements title attributes 2024-03-13 07:58:36 -04:00
Andreas Kling
72e6581585 LibWeb: Store copy of MutationObserver set in a MarkedVector
While iterating over MutationObservers in the microtask callback, we
need to keep them in a MarkedVector to ensure they don't get GC'd.
2024-03-13 09:41:55 +01:00
Tim Ledbetter
fc1f037cd1 LibWeb: Implement the window.opener attribute
This returns a reference to the window that opened the current window.
2024-03-13 08:06:00 +00:00