Commit graph

15943 commits

Author SHA1 Message Date
Leonardo Duarte 335fae9a71 LibC: Return early in time_to_tm for large time_t
POSIX says that localtime should fail with EOVERFLOW if the result
cannot be represented, which is the case for most large (in absolute
value) time_t inputs, since they overflow (or underflow) tm_year, which
is an int. This patch introduces this functionality. Previously, tm_year
just overflowed (or underflowed) silently.

Incidentally, this partially fixes #12729 without solving the root
problem, which is that time_to_tm is linear in its input to determine
the number of years since epoch.

This means that the bash port mktime test no longer times-out in 60s,
but it still fails (faster) in some other place. Due to underlying issue
in the algorithm, the worst case inputs still take a couple of seconds
on my machine.
2022-04-19 10:06:23 -04:00
Sam Atkins 9272c3283b LibWeb: Add missing StyleValue::equals() methods
Every StyleValue type now has its own `equals()` method, rather than
relying on the default "compare the to_string() output" method, which
has now been removed. This logic is still used by UnresolvedSV and
CalculatedSV, because it's probably the best option for them unless
performance becomes a real issue.

Also took this opportunity to move all the `equals()` implementations
into the .cpp file, which may or may not actually help with compile
times but StyleValue.h is huge and included everywhere, so it can't
hurt.
2022-04-18 21:30:51 +02:00
Sam Atkins ce5914230f LibWeb: Actually use BorderRadiusShorthandStyleValue
Somehow we were never actually using this before, but parsing the
property as a StyleValueList instead.
2022-04-18 21:30:51 +02:00
Sam Atkins 025ee02144 LibWeb: Add missing [as/is]_border_radius_shorthand() methods 2022-04-18 21:30:51 +02:00
Sam Atkins d9afc2d6f2 LibWeb: Rename CombinedBorderRadiusSV -> BorderRadiusShorthandSV 2022-04-18 21:30:51 +02:00
Ali Mohammad Pur e1cd36559d LibJS: Make the BC generator.next(value) work
This used to put the value in the previous frame's accumulator register,
which is only correct for the first invocation of the generator.
2022-04-18 23:59:30 +04:30
Ali Mohammad Pur d5791c85b4 LibJS: Avoid copying the frame into the interpreter in BC generators 2022-04-18 23:59:30 +04:30
Eli Youngs 04763c4a12 Spreadsheet: Sort functions by name in the help window 2022-04-18 17:36:34 +02:00
Ali Mohammad Pur dd5fb7b32a LibLine: Reset next suggestion index when resetting suggestions
Otherwise we'd end up starting at the previous index on another
suggestion list.
2022-04-18 19:53:10 +04:30
Ali Mohammad Pur ae27d7e442 Shell: Make program-based completion with no actual token possible
31ca48e made this default to paths, but now that we have a few sensible
ways to complete things, let's make those work too.
For instance, prior to this `kill <tab>` would've suggested paths, but
now it will suggest processes.
2022-04-18 19:53:10 +04:30
Ali Mohammad Pur 1699ddc186 LibLine: Make it possible to avoid autocompletion if requested
Setting 'allow_commit_without_listing' to false will now make LibLine
show the suggestion before actually committing to it; this is useful for
completions that will replace all the user input, where mistakes can go
unnoticed without some visual cue.
2022-04-18 19:53:10 +04:30
Ali Mohammad Pur d5b3998d23 LibLine: Respect the provided completion static offset
Now that we can resolve these correctly and they're per-suggestion, we
can finally use them for their intended purpose of letting suggestions
overwrite stuff in the buffer.
2022-04-18 19:53:10 +04:30
Ali Mohammad Pur 4ea9ca06b4 Shell: Allow completions to request further action from the shell
The shell now expects a JSON object of the form {"kind":<kind>,...} per
line in the standard output of the completion process, where 'kind' is
one of:
- "plain": Just a plain suggestion.
- "program": Prompts the shell to complete a program name starting with
  the given "name".
- "proxy": Prompts the shell to act as if a completion for "argv" was
  requested.
- "path": Prompts the shell to complete a path given the "base" and
  "part" (same as completing part in cwd=base).
2022-04-18 19:53:10 +04:30
Ali Mohammad Pur 4ede121d31 Shell: Add support for regex match patterns
We previously allowed globs as match pattern, but for more complex
matching needs, it's nice to have regular expressions.
And as the existing "name a part of the match" concept maps nicely to
named capture groups, we can simply reuse the same code and make groups
with names available in the match body.
2022-04-18 19:53:10 +04:30
Ali Mohammad Pur 6aceec4535 LibLine: Don't use fdopen() for stream in edit_in_external_editor()
We would have to fclose() it to be clean and nice, but that would close
the fd; instead just duplicate it and write through that, this makes it
actually write to the file.
2022-04-18 19:53:10 +04:30
Karol Kosek 35cb5ea47c Utilities/profile: Call split_view() using StringView for command parts
This fixes the always appearing 'No such file' error when using the -c
flag, as the String was deconstructed right after running this line.
2022-04-18 14:17:01 +02:00
Sam Atkins 00782d9a59 LibWeb: Disallow trailing commas in transform function arguments 2022-04-18 14:16:28 +02:00
Sam Atkins b3a6044fd8 LibWeb: Disallow non-whitespace tokens after "none" in transform
Before this, a declaration like `transform: none yellow 20;` would be
parsed as `transform: none;`. Now it's correctly rejected as invalid.
2022-04-18 14:16:28 +02:00
Sam Atkins a52f6fb5b0 LibWeb: Use TransformFunctionMetadata when parsing their arguments
Now, the parser will reject a transform function if:
- There are too many arguments.
- There are too few arguments.
- An argument is the wrong type.
2022-04-18 14:16:28 +02:00
Sam Atkins 61ad39b110 LibWeb: Use generated TransformFunction enum and functions 2022-04-18 14:16:28 +02:00
Sam Atkins 5f3498d50f LibWeb: Add code generator for CSS transform functions
This first step just generates the TransformFunction enum, but more will
follow.
2022-04-18 14:16:28 +02:00
Karol Kosek 807101e394 ThemeEditor: Remove unused model classes
They have been replaced by generic RoleModel class.
2022-04-18 12:58:23 +02:00
Karol Kosek 171ecdd691 ThemeEditor: Use new RoleModel template class 2022-04-18 12:58:23 +02:00
Karol Kosek 8817d3ec58 ThemeEditor: Add generic RoleModel template class
This is to simplify the code, as Color, Alignment, Flag, Metric and Path
RoleModel classes looked exactly the same.

Additionally, I've added a try_create() function for error propagation.
:^)
2022-04-18 12:58:23 +02:00
Sam Atkins 73552c1856 Userland: Always construct Application with try_create() 2022-04-18 12:57:34 +02:00
Sam Atkins cd7037afd5 SystemMonitor: Remove MakeInspectable::Yes from constructor
I think this was left in by mistake. No application should be hard-coded
as inspectable.
2022-04-18 12:57:34 +02:00
Sam Atkins f240def414 LibCore: Allow inspecting any process launched with MAKE_INSPECTABLE=1
For now, EventLoop and Application still have a make_inspectable
parameter, so that when working on an application you can temporarily
hard-code it to be inspectable rather than having to set the env var
each time.
2022-04-18 12:57:34 +02:00
Eli Youngs d20ff6c891 HexEditor: Show endianness in the value inspector 2022-04-18 09:25:38 +04:30
Linus Groh 472ff7a6d4 LibJS: Don't coerce this value in %IteratorPrototype%[@@iterator]
Another day, another mistake that's been there for a long time but
would've been immediately obvious when adding spec comments. :^)
2022-04-18 00:24:02 +02:00
Linus Groh ee1379520a LibJS: Add missing whitespace around namespace curly braces 2022-04-17 23:00:35 +02:00
stelar7 196dada7e2 LibWeb: Dont abort when parsing data- properties that contain dashes 2022-04-17 20:08:27 +03:00
Thitat Auareesuksakul c949a4db2d DHCPClient: Send ParameterRequestList option with DHCPRequest packet
We'll need SubnetMask and Router options to be returned with the ACK
packet. So, it's a good idea to request them explicitly in this packet.
2022-04-17 10:25:01 +04:30
Thitat Auareesuksakul 01a602cb51 DHCPClient: Send ServerIdentifier option with DHCPRequest packet
Some DHCP servers (including Mikrotik ones) will NAK the request if the
ServerIdentifier option is not sent with the DHCPRequest packet.
2022-04-17 10:25:01 +04:30
Michiel Visser fa18c283dc LibTLS: Cleanup of verify_chain and verify_certificate_pair 2022-04-17 10:10:19 +04:30
Michiel Visser be654dad8a LibCrypto: Certificate parse IP address SAN
Subject alternative name entries containing IP addresses will now be
parsed and added to the list of SANs. This should allow for certificate
verification when accessing IP addresses directly.
2022-04-17 10:10:19 +04:30
Michiel Visser 7bc3b193c0 LibTLS: Add option to allow self-signed certificates
With this option enabled self-signed certificates will be accepted,
eventhough they cannot be verified.
2022-04-17 10:10:19 +04:30
Michiel Visser 804af863b4 LibCrypto+LibTLS: Implement Key Usage and Basic Constraints extensions
Root and intermediate CA certificates should have these extensions set
to indicate that they are allowed to sign other certificates. The values
reported in these extensions is now also checked by `verify_chain` to
make sure no non-CA certificates are used to sign another certificate.

The certificate parser now also aborts when a critical extension is
detected which is unsupported, as is required by the specification.
2022-04-17 10:10:19 +04:30
Michiel Visser a6e465fba2 LibCrypto: Implement custom BitStringView for ASN.1 decoder
The ASN.1 decoder was originally using AK::BitmapView for decoded
BitStrings, however the specification requires that the bits are stored
in a byte from the most significant to the least significant.

Storing three bits '110' would result in a byte '1100 0000', i.e. 0xC0.
However, AK::BitmapView expects the bits to be stored at the bottom like
'0000 0110', i.e. 0x06. For the current uses the data was always a
multiple of eight bits, resulting in complete bytes, which could
directly be interpreted correctly.

For the implementation of the key usage extension of certificates the
correct implementation of the BitString is required.
2022-04-17 10:10:19 +04:30
Michiel Visser b16b61f6bc LibCrypto: Fix inverted boolean decoded error in ASN.1
ASN.1 encodes booleans as false is zero and true is non-zero. The
decoder currently returned true when the boolean was zero.

Since this decoder was barely used it did not cause any problems,
however for support of other certificate extensions the correct version
is required.
2022-04-17 10:10:19 +04:30
Michiel Visser 976bb715e0 LibTLS: Correct matching hostname with certificate subject
The wildcard specified in a certificates subject can only match a single
level of subdomains. Originally, this function could match multiple
levels of subdomains with a single "*.".

As an example, https://wrong.host.badssl.com/ should fail to load, as
the certificate provided by the server only specifies "*.badssl.com".
However this was correctly matching anyway. With this change this page
now correctly fails to load.
2022-04-17 10:10:19 +04:30
Michiel Visser 331092d25a LibTLS: Add references to RFC5246 for the verify procedure 2022-04-17 10:10:19 +04:30
Michiel Visser d78813d902 LibTLS: Simplify the way verify_chain is called
The `build_rsa_pre_master_secret` function originally called
`verify_chain_and_get_matching_certificate`, which verified the chain
and returned a certificate matching the specified hostname.

Since the first certificate in the chain should always be the one
matching with the hostname, we can simply use that one instead. This
means we can completely remove this method and just use `verify_chain`.

To make sure the hostname is still verified, `verify_chain` now also
checks that the first certificate in the chain matches the specified
hostname. If the hostname is empty, we currently fail the verification,
however this basically never happen, as the server name indication
extension is always used.
2022-04-17 10:10:19 +04:30
Michiel Visser f8ce0eb648 LibTLS: ASN1 parse_utc_time handle pre 2000 years
In this format the year is specified using two digits. In the case that
these digits are 50 or more, we should assume that the year is in
1950-1999. If it is 49 or less, the year is 2000-2049.

This is specified in RFC5280 section 4.1.2.5.1.
2022-04-17 10:10:19 +04:30
Michiel Visser fea5aeda0b LibTLS: Verify the certificate chain sent by the server
With this change the certificate chain sent by the server will actually
be verified, instead of just checking the names of the certificates.

To determine if a certificate is signed by a root certificate, the list
of root certificates is now a HashMap mapping from the unique identifier
string to the certificate. This allows us to take the issuer of a
certificate and easily check if it is a root certificate. If a
certificate is not signed by a root certificate, we will check that it
is signed by the next certificate in the chain.

This also removes the ad-hoc checking of certificate validity from
multiple places, and moves all checking to the verify_chain.
2022-04-17 10:10:19 +04:30
Michiel Visser d5cef41bb6 LibTLS: Parse Certificate signature algorithm and value
This part of the certificate was originally just skipped, however it
will be needed to check the validity of the certificate.
2022-04-17 10:10:19 +04:30
Michiel Visser 2b416e5faa Base+LibTLS: Update CA Certificates list with actual certificates
The CA certificates list now contains the actual certificate data for
approximatly a hundred certificate authorities. These certificates were
generated from https://mkcert.org, which uses the Mozilla CA certificate
list.

This also updates the code for reading the CA certificates.
2022-04-17 10:10:19 +04:30
Michiel Visser 707b222913 LibTLS: Add certificate chain validation to DHE and ECDHE key exchange
The RSA key exchange was the only one actually verifying the validity of
the certificate chain supplied by the server. Now the DHE and ECDHE key
exchanges also check the certificate chain.
2022-04-17 10:10:19 +04:30
Itamar f4cca20972 LibCpp: Parse inheritance 2022-04-17 10:09:23 +04:30
Jelle Raaijmakers 757f506fda LibGL: Implement GLContext::frontbuffer() 2022-04-17 09:58:29 +04:30
Jelle Raaijmakers dad829de50 LibGfx: Add Bitmap::visually_equals() 2022-04-17 09:58:29 +04:30